I have the following code which loops through a number of fields, which their ID prefix and suffix is the same, see code below. I am stuck trying to add the total values of all related fields and displaying it on textbox Id txtTOTAL20, txtTOTAL40 and txtTOTAL50. This is what I have so far (which doesn't work)
for (var i = 1; i < 14; i++) {
x = i + 1
var field1 = "txtF" + i + "_1";
var field2 = "txtF" + i + "_2";
var field3 = "txtF" + i + "_3"
FIELD20 = FIELD20 + parseInt(field1.value);
FIELD40 = FIELD40 + parseInt(field2.value);
FIELD50 = FIELD50 + parseInt(field3.value);
var text = document.getElementById('txtTOTAL20');text.value = FIELD20;
var text = document.getElementById('txtTOTAL40');text.value = FIELD40;
var text = document.getElementById('txtTOTAL50');text.value = FIELD50;
}
Any ideas?