我有10個文本框名稱qty1-10,price1-10和total1-10爲每個這些。我做的是增加qty1 +價格1 =共1頁,qty2 + price2 =共2等的值..JavaScript的多個文本框
這是我當前的代碼 -
function Add()
{
var qty1 = document.getElementById('qty1').value;
var u_price1 = document.getElementById('price1').value;
if (qty1 == "") {
if (u_price1 == "") {
document.form1.total1.value = "null";
return;
}
document.form1.total1.value = "null";
return;
}
else
{
document.form1.total1.value = Number(qty1) + Number(u_price1);
}
}
現在我想寫一個for循環,將使用相同的代碼,但將qty1的名稱更改爲qty2等等。
謝謝,現在高達55%。將做更多。 – user970225 2012-02-15 18:56:07