- Sat Oct 15, 2022 6:26 am
#830249
hello all
i need to know what is wrong in this calculation? i need to calculate the 6 cloulmns numbers to be in the total field in 7th columns, the poroblem that when one field left empty the sum dont work. i need the code work even if level1 or 2 or 3 or 4 or 5 is empty
$("form").setOnchange(function(field, newVal, oldVal) {
var totalRows = $("#scores").getNumberRows();
for (var i = 1; i <= totalRows; i++) {
level1 = parseFloat($("#scores").getValue(i, 2));
level2 = parseFloat($("#scores").getValue(i, 3));
level3 = parseFloat($("#scores").getValue(i, 4));
level4 = parseFloat($("#scores").getValue(i, 5));
level5 = parseFloat($("#scores").getValue(i, 6));
total =level1 + level2 + level3 + level4 + level5;
$("#scores").setValue(total, i, 7);
}
});
i need to know what is wrong in this calculation? i need to calculate the 6 cloulmns numbers to be in the total field in 7th columns, the poroblem that when one field left empty the sum dont work. i need the code work even if level1 or 2 or 3 or 4 or 5 is empty
$("form").setOnchange(function(field, newVal, oldVal) {
var totalRows = $("#scores").getNumberRows();
for (var i = 1; i <= totalRows; i++) {
level1 = parseFloat($("#scores").getValue(i, 2));
level2 = parseFloat($("#scores").getValue(i, 3));
level3 = parseFloat($("#scores").getValue(i, 4));
level4 = parseFloat($("#scores").getValue(i, 5));
level5 = parseFloat($("#scores").getValue(i, 6));
total =level1 + level2 + level3 + level4 + level5;
$("#scores").setValue(total, i, 7);
}
});