Adding times in HH:MM to get total time in HH:MM
Hi community
I have a table of up to possibly 9 elapsed time fields (Flight Time1-9), HH:MM. I wantt to total them all up to make a total time (Total Time) in HH:MM. hereis my code.
// get the value of time fields 1 - 9
var cTime1 = this.getField("Flight Time1").value;
var cTime2 = this.getField("Flight Time2").value;
var cTime3 = this.getField("Flight Time3").value;
var cTime4 = this.getField("Flight Time4").value;
var cTime5 = this.getField("Flight Time5").value;
var cTime6 = this.getField("Flight Time6").value;
var cTime7 = this.getField("Flight Time7").value;
var cTime8 = this.getField("Flight Time8").value;
var cTime9 = this.getField("Flight Time9").value;
// split the time fields value into an array of hours and minutes
// convert the hours to minutes and compute the total minutes as a variable
var aTime1 = cTime1.split(":");
var nMinutes1 = Number(aTime1[0])*60 + Number(aTime1[1]);
var aTime2 = cTime2.split(":");
var nMinutes2 = Number(aTime2[0])*60 + Number(aTime2[1]);
var aTime3 = cTime3.split(":");
var nMinutes3 = Number(aTime3[0])*60 + Number(aTime3[1]);
var aTime4 = cTime4.split(":");
var nMinutes4 = Number(aTime4[0])*60 + Number(aTime4[1]);
var aTime5 = cTime5.split(":");
var nMinutes5 = Number(aTime5[0])*60 + Number(aTime5[1]);
var aTime6 = cTime6.split(":");
var nMinutes6 = Number(aTime6[0])*60 + Number(aTime6[1]);
var aTime7 = cTime7.split(":");
var nMinutes7 = Number(aTime7[0])*60 + Number(aTime7[1]);
var aTime8 = cTime8.split(":");
var nMinutes8 = Number(aTime8[0])*60 + Number(aTime8[1]);
var aTime9 = cTime9.split(":");
var nMinutes9 = Number(aTime9[0])*60 + Number(aTime9[1]);
// add all the miutes variables
var nTotalMinutes = nMinutes1 + nMinutes2 + nMinutes3 + nMinutes4 + nMinutes5 + nMinutes6 + nMinutes7 + nMinutes8 + nMinutes9;
// get the whole hours from the total of all minutes
var nHours = Math.floor(nTotalMinutes/60);
// get jus the minutes less than 1 hour (60 minutes) for the total of all minutes
var nMinutes = nTotalMinutes%60;
// make a string variable of the hours, ":", and minutes
var sTotal Time = nHours + ":" + nMinutes;
event.value = sTotal Time; // fillin the field's value
// build time strings or hours, ":", and minutes with leading zero
var sTotal Time = nHours + ":" + util.printf("%,102.0f", nMinutes);
However, there is no result displaying! Where have I gone wrong??

