I have a script that completes a calculation for each row of my table and then add the rows together. The calculation is alway correct if it consists of the first row only. For some reason, I'm getting an incorrect calculation when the other rows are included in the calculation.
var total = 0;
var a1 = Number(this.getField("o1i").value);
var a2 = Number(this.getField("o1iother").value);
var b1 = Number(this.getField("o2i").value);
var b2 = Number(this.getField("o2iother").value);
var c1 = Number(this.getField("o3i").value);
var c2 = Number(this.getField("o3iother").value);
var d1 = Number(this.getField("o4i").value);
var d2 = Number(this.getField("o4iother").value);
var e1 = Number(this.getField("o5i").value);
var e2 = Number(this.getField("o5iother").value);
var t = Number(this.getField("time").value);
for(var i=1; i<=15; i++){
if(this.getField("ins."+i).valueAsString == "o1" &&
this.getField("mins"+i).valueAsString != "")
total += t*a1+a2;
else if(this.getField("ins."+i).valueAsString == "o2" &&
this.getField("mins"+i).valueAsString != "")
total += t*b1+b2;
else if(this.getField("ins."+i).valueAsString == "o3" &&
this.getField("mins"+i).valueAsString != "")
total += t*c1+c2;
else if(this.getField("ins."+i).valueAsString == "o4" &&
this.getField("mins"+i).valueAsString != "")
total += t*d1+d2;
else if(this.getField("ins."+i).valueAsString == "o5" &&
this.getField("mins"+i).valueAsString != "")
total += t*e1+e2;}
if(total == 0)event.value = 0;
else
event.value = total;