2013-07-25 102 views
1

属性“价值”这个计算器工作在HTML罚款,当我把它添加到WordPress的安装,现在抛出这个错误:遗漏的类型错误无法读取的不确定

遗漏的类型错误无法读取的未定义的属性“值”。

Chrome控制台说这是这条线。

var TotalAreaAccum = ((document.forms[0].Area1LenFt.value * 1)+(document.forms[0].Area1LenIn.value * 1)/12)*((document.forms[0].Area1WidFt.value * 1)+(document.forms[0].Area1WidIn.value * 1)/12); 

这里是在HTML工作计算,当添加到一个PHP网站(WP),它停止工作它的。 Example Link。任何帮助将不胜感激

<script language="JavaScript"> 
    function Round2Dollars(amount) { 
// Converts amount to a formatted string with leading dollar sign 
// and rounded to 2 decimal places 
// Copyright 1998 Millennium Software, Inc by Paul F Johnson www.msi-web.com 
// 
var dollars = "$"+Math.floor(amount)+"."; 
var cents = 100*(amount-Math.floor(amount))+0.5; 
result = dollars + Math.floor(cents/10) + Math.floor(cents%10); 
return result; 
    } 

    function Round2(amount) { 
// Converts amount to a formatted string 
// rounded to 2 decimal places 
// Copyright 1998 Millennium Software, Inc by Paul F Johnson www.msi-web.com 
// modified from Round2Dollars by drs 2/24/00 
var dollars = Math.floor(amount)+"."; 
var cents = 100*(amount-Math.floor(amount))+0.5; 
result = dollars + Math.floor(cents/10) + Math.floor(cents%10); 
return result; 
} 

    function calcul8() { 
// Calculations for form 
// Calculate the total square footage of up to five rectangles. 
// 
var TotalAreaAccum = ((document.forms[0].Area1LenFt.value * 1)+(document.forms[0].Area1LenIn.value * 1)/12)*((document.forms[0].Area1WidFt.value * 1)+(document.forms[0].Area1WidIn.value * 1)/12); 
TotalAreaAccum = TotalAreaAccum + ((document.forms[0].Area2LenFt.value * 1)+(document.forms[0].Area2LenIn.value * 1)/12)*((document.forms[0].Area2WidFt.value * 1)+(document.forms[0].Area2WidIn.value * 1)/12); 


document.forms[0].TotalSqFt.value = TotalAreaAccum; 
document.forms[0].WasteSqFt.value = Round2(TotalAreaAccum * .05); 
document.forms[0].TotalMatlReq.value = Round2(TotalAreaAccum * 1.05); 
document.forms[0].TotalCost.value = Round2Dollars(document.forms[0].TotalMatlReq.value * document.forms[0].CostPSF.value); 

    } 

    function resetform() { 
// Reset field on form to default values 
document.forms[0].Area1LenFt.value = "0"; 
document.forms[0].Area1LenIn.value = "0"; 
document.forms[0].Area1WidFt.value = "0"; 
document.forms[0].Area1WidIn.value = "0"; 
document.forms[0].Area2LenFt.value = "0"; 
document.forms[0].Area2LenIn.value = "0"; 
document.forms[0].Area2WidFt.value = "0"; 
document.forms[0].Area2WidIn.value = "0"; 
document.forms[0].CostPSF.value = "0.00"; 
document.forms[0].TotalSqFt.value = "0"; 
document.forms[0].WasteSqFt.value = "0"; 
document.forms[0].TotalMatlReq.value = "0"; 
document.forms[0].TotalCost.value = "0.00"; 
    } 
    </script> 
+0

你没有一个元素与*** ***名字'Area1LenIn'在HTML中的第一个表单中。 – adeneo

+0

我得到'TypeError:document.forms [0] .CostPSF未定义@ http://anvilflooring.ca/calculator.html:181' – Oriol

回答

0

您没有任何元素与CostPSF名在HTML

相关问题