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) 时,它会停止工作。示例链接。任何帮助将不胜感激

 <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>
4

1 回答 1

0

您在 HTML 中没有任何具有CostPSF名称的元素

于 2013-07-25T16:31:35.577 回答