gpt4 book ai didi

JavaScript 计算定价表单在 PC 上不起作用。适用于 Mac。有人能找到错误吗?

转载 作者:行者123 更新时间:2023-11-30 18:55:19 25 4
gpt4 key购买 nike

谁能帮我找出问题所在?我永远感谢这个网站已经提供的帮助,并感谢任何建议或想法。谢谢。

实际页面可以在这里看到:http://www.procollage.com/pricing/photo-collage-pricing.html

 <script LANGUAGE="JavaScript">
function calculate(PricingForm) {
height = PricingForm.height.value;
width = PricingForm.width.value;
photos = PricingForm.photos.value;
lgtext = PricingForm.lgtext.value;
mountlam = PricingForm.mount.value;
mountlam = PricingForm.lam.value;

price = GetPrice(PricingForm, height, width, photos, lgtext, mount, lam)
document.PricingForm.collageEstimate.value = "$" + RoundToPennies(price);
}

function GetPrice(PricingForm, height, width, photos, lgtext, mount, lam) {

price = height * width;
price = price / 144;
pricetwo = price; // for lookup later
price = price * 15;

price = (PricingForm.lgtext.checked) ? price + 20 : price;
price = (PricingForm.mount.checked) ? price + pricetwo * 5 : price;
price = (PricingForm.lam.checked) ? price + pricetwo * 5 : price;

return (photos * 4.95) + price;
}

function RoundToPennies(n) {
pennies = n * 100;
pennies = Math.round(pennies);
strPennies = "" + pennies;
len = strPennies.length;
return strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len);
}

</script>

最佳答案

calculate 函数中既没有mount 也没有lam 变量,我认为是复制/粘贴错误,看:

function calculate(PricingForm) {
//...
mountlam = PricingForm.mount.value; // <--- the same identifier
mountlam = PricingForm.lam.value; // <---

price = GetPrice(PricingForm, height, width, photos, lgtext, mount, lam);
//.. ^ ^
}

应该是:

//...
mount = PricingForm.mount.value;
lam = PricingForm.lam.value;

price = GetPrice(PricingForm, height, width, photos, lgtext, mount, lam);
//..

另请注意,如果您在不使用 var 语句的情况下进行赋值,这些变量将成为全局变量...

关于JavaScript 计算定价表单在 PC 上不起作用。适用于 Mac。有人能找到错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2331158/

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