Answered
Time Caculation - Calculated field value still remains after resetting all the fields.
Hi,
I got this script of calculation of time
on this community and i modified it to suit my form everything is working fine.. but when i reset the form .. everything should be blank or 0 but the calculated field still keeps the last calculated value;
Here is the script (run through calculate tab):
var cStartDate = this.getField("Date").valueAsString;
var cStartTime1 = this.getField("IN_TIME1").valueAsString;
var cStartDateFormat = "dd-mmm-yyyy";
var cStartTimeFormat = "h:MM tt";
cStartTime1 = AdjustMidnight(cStartTime1);
var cEndDate = this.getField("Date").valueAsString;
var cEndTime1 = this.getField("OUT_TIME1").valueAsString;
var cEndDateFormat = "dd-mmm-yyyy";
var cEndTimeFormat = "h:MM tt";
cEndTime1 = AdjustMidnight(cEndTime1);
event.value = 0;
if(cStartDate != "" && cStartTime1 != "" && cEndDate != "" && cEndTime1 != "")
{
var t1 = DateTime2Min(cEndDateFormat + " " + cEndTimeFormat, cEndDate + " " + cEndTime1) - DateTime2Min(cStartDateFormat + " " + cStartTimeFormat, cStartDate + " " + cStartTime1);
}
var cStartDate = this.getField("Date").valueAsString;
var cStartTime2 = this.getField("IN_TIME2").valueAsString;
var cStartDateFormat = "dd-mmm-yyyy";
var cStartTimeFormat = "h:MM tt";
cStartTime2 = AdjustMidnight(cStartTime2);
var cEndDate = this.getField("Date").valueAsString;
var cEndTime2 = this.getField("OUT_TIME2").valueAsString;
var cEndDateFormat = "dd-mmm-yyyy";
var cEndTimeFormat = "h:MM tt";
cEndTime2 = AdjustMidnight(cEndTime2);
event.value = 0;
if(cStartDate != "" && cStartTime2 != "" && cEndDate != "" && cEndTime2 != "")
{
var t2 = DateTime2Min(cEndDateFormat + " " + cEndTimeFormat, cEndDate + " " + cEndTime2) - DateTime2Min(cStartDateFormat + " " + cStartTimeFormat, cStartDate + " " + cStartTime2);
}
event.value = t1 + t2;
