即時通訊在javascript中是noob,並且想知道當總值低於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");
}
});
哪裏標記?誰調用了'checkTotal'? 'sum'沒有在準備好的回調中定義! – gdoron