คำนวณผลรวมของarray..

<head>
function sumremain() {
for(var i=0; i<15; i++){
if(document.form1.itemm(i).checked){
var sum=0;
for(var i=0; i<=document.form1.itemm(i).checked;i++){
//if(document.form1.itemm(i).checked){
 document.form1.amo(i).value = parseFloat(document.form1.qty(i).value) * parseFloat(document.form1.price(i).value);
//}
 sum += parseFloat(document.form1.amo(i).value);
 document.form1.total.value = sum;
 }
 return sum;
 }
 }
}
</head>
<body>
<form  method="post" name="form1" id="form1">
<table width="100%">
<? for($i=1;$i<=15;$i++){ ?>
<tr><td><div align="center">
                <input name="itemm[]" type="checkbox" id="itemm" >
                </div></td>
<td height="27"><div align="center"><input name="qty[]" type="text" id="qty" size="3" disabled onkeyup="sumremain();" /></div></td>
              <td height="27"><div align="center"><input name="price[]" type="text" id="price" size="5" disabled  onkeyup="sumremain();" /></div></td>
              <td height="27"><div align="center"><input name="amo[]" type="text" id="amo" size="5" disabled /></div></td>
</tr>
<? } ?>
<tr><td><div align="right">Total</div></td>
              <td height="27"><div align="center">
                <input name="total" type="text" id="total" size="5"/>
              </div></td>
</tr>
</table></form>
</body>

 จากโค๊ดน่ะค่ะ รบกวนช่วยดูให้หน่อยว่ามันผิดตรงไหน  เวลาลองรันผลดู แถวที่ 1,2 ก็คำนวณผลลัพธ์ให้ปกติแต่ทำไมแถวต่อๆไปถึงไม่คำนวณให้อ่ะค่ะ 

01 พ.ย. 2551 1 3,754

ต้องกำหนดชื่อให้ text ตรงๆครับ เช่น txt[<?php echo $i?>] ถึงจะหาเจอ
#1
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^