Script to calculate text fields
I've entered the following script in a text fields named 'TotalOTHrs1' and 'TotalRegHrs2', which I need to calculate from text fields 'Hrs1' to 'Hrs8. I also have text fields named 'TotalOTHrs2' and 'TotalRegHrs2' which I need to calculate from text fields 'Hrs9' to Hrs 16'. The script below works for an all the fields but I need help figuring out how to include this in my script to make it calculate only the fields I need. Thank you!
//Total OT Hours
var maxFields = 35; //
var total = 0;
for (var i=1; i<=maxFields; i++) {
if (this.getField("Exception"+i).valueAsString!=" ")
if (this.getField("Exception"+i).valueAsString!="Lead Ranger Step 3")
if (this.getField("Exception"+i).valueAsString!="Senior Park Ranger")
if (this.getField("Exception"+i).valueAsString!="Sick")
if (this.getField("Exception"+i).valueAsString!="Sick No Pay")
if (this.getField("Exception"+i).valueAsString!="Leave No Pay")
total+=Number(this.getField("Hrs"+i).valueAsString);
}
event.value = total;
//Total Reg Hours
var maxFields = 35; //
var total = 0;
for (var i=1; i<=maxFields; i++) {
if (this.getField("Exception"+i).valueAsString!="Paid OT1.5")
if (this.getField("Exception"+i).valueAsString!="Bank OT1.5")
if (this.getField("Exception"+i).valueAsString!="Paid OT2.0")
if (this.getField("Exception"+i).valueAsString!="Bank OT2.0")
if (this.getField("Exception"+i).valueAsString!="Meal Break")
total+=Number(this.getField("Hrs"+i).valueAsString);
}
event.value = total;
