gpt4 book ai didi

javascript - 未捕获的类型错误无法读取未定义的属性 'value'

转载 作者:行者123 更新时间:2023-11-28 09:00:12 28 4
gpt4 key购买 nike

这个计算器在 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>

最佳答案

HTML 中没有任何名称为 CostPSF 的元素

关于javascript - 未捕获的类型错误无法读取未定义的属性 'value',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17862752/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com