我是 javascript 的菜鸟,想知道当总值低于 0 时如何显示警报消息。有问题的页面在这里(http://cashmoneypaid.com/order-form-phones-work)和我尝试过的脚本如下。非常感谢帮忙。
function checkTotal() {
document.listForm.total.value = '';
var sum = 20;
for (i = 0; i < document.listForm.choice.length; i++) {
if (document.listForm.choice[i].checked) {
sum = sum + parseInt(document.listForm.choice[i].value);
}
}
document.listForm.total.value = sum;
}
$("#total").ready(function() {
if (sum > 0) {
alert("We are sorry, but at this time we can not offer you any money for your item");
}
});