Hello I have used this code to add up time fields and works great. However, it doesn't work if one or more of the fields are left blank. Is there any way to make it so that it ignores any empty fields?
// get the value of time fields 1 - 21
var cTime1 = this.getField("TotalTime1").value;
var cTime2 = this.getField("TotalTime2").value;
... // repeat for 3 - 20
var cTime21 = this.getField("TotalTime21").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]);
.... // repeat for 3 - 20
var aTime21 = cTime21.split(":");
var nMinutes21 = Number(aTime21[0])*60 + Number(aTime21[1]);
// add all the miutes variables
var nTotalMinutes = nMinutes1 + nMinutes2 + ... nMinutes21; // fillin the 3 - 20 times
// 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 sTotalAllTime = nHours + ":" + nMinutes;
// display a literal and total time
console.show();
console.clear();
console.println("All time total: " + sTotalAllTime);
app.alert("All time total: " + sTotalAllTime, 0, 1);
event.value = sTotalAllTime; // fillin the field's value
George Kaiser