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");
}
});