function calcfunc ('{$i}') {
var val1 = parseFloat(document.calc.month1('{$i}').value);
var val2 = parseFloat(document.calc.month2('{$i}').value);
var val3 = parseFloat(document.calc.month3('{$i}').value);
var val4 = parseFloat(document.calc.month4('{$i}').value);
var val5 = parseFloat(document.calc.month5('{$i}').value);
var val6 = parseFloat(document.calc.month6('{$i}').value);
var val7 = parseFloat(document.calc.month7('{$i}').value);
var val8 = parseFloat(document.calc.month8('{$i}').value);
var val9 = parseFloat(document.calc.month9('{$i}').value);
var val10 = parseFloat(document.calc.month10('{$i}').value);
var val11 = parseFloat(document.calc.month11('{$i}').value);
var val12 = parseFloat(document.calc.month12('{$i}').value);
var val13 = parseFloat(document.calc.month13('{$i}').value);
var val14 = parseFloat(document.calc.month14('{$i}').value);
var val15 = parseFloat(document.calc.month15('{$i}').value);
document.calc.ret('{$i}').value=val1+val2+val3+val4+val5+val6+val7+val8+val9+val10+val11+val12+val13+val14+val15;
}
ผมขอถามหน่อยคับ id ที่ต่อ month1-15 มันเอาค่าตรงไหนคำนวณคับ Code (PHP)
function calcfunc(id) {
var val1 = parseFloat(document.calc.month1[id].value);
var val2 = parseFloat(document.calc.month2[id].value);
var val3 = parseFloat(document.calc.month3[id].value);
var val4 = parseFloat(document.calc.month4[id].value);
var val5 = parseFloat(document.calc.month5[id].value);
var val6 = parseFloat(document.calc.month6[id].value);
var val7 = parseFloat(document.calc.month7[id].value);
var val8 = parseFloat(document.calc.month8[id].value);
var val9 = parseFloat(document.calc.month9[id].value);
var val10 = parseFloat(document.calc.month10[id].value);
var val11 = parseFloat(document.calc.month11[id].value);
var val12 = parseFloat(document.calc.month12[id].value);
var val13 = parseFloat(document.calc.month13[id].value);
var val14 = parseFloat(document.calc.month14[id].value);
var val15 = parseFloat(document.calc.month15[id].value);
document.calc.ret[id].value=val1+val2+val3+val4+val5+val6+val7+val8+val9+val10+val11+val12+val13+val14+val15;
}