2013-07-25 96 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

相關問題