I have problem with this time calculation script:
var vTime1 = TimeOut1.rawValue;
var vTime2 = TimeIn1.rawValue;
if (vTime1.length == 4 && vTime2.length == 4) {
var vTime1Minutes = parseInt(vTime1.substring(0, 1))*600 + parseInt(vTime1.substring(1, 2))*60 + parseInt(vTime1.substring(2, 4));
var vTime2Minutes = parseInt(vTime2.substring(0, 1))*600 + parseInt(vTime2.substring(1, 2))*60 + parseInt(vTime2.substring(2, 4));
if (vTime1Minutes > vTime2Minutes)
vTime1 = vTime2Minutes+1440 - vTime1Minutes;
else
vTime1 = vTime2Minutes - vTime1Minutes;
}
var Hours = Math.floor(vTime1/60);
var Minutes = vTime1%60;
if (Minutes < 10)
Minutes = "0" + Minutes;
this.rawValue = Hours + ":" + Minutes;
the purpose is to calculate the time between hours, it works fine once the fields are inserted but once saved and reopen the calcultion is weird.
For a similar script i get a NaN;Nan result, probably the error on the one above can solve even the second...
Can someone help?
Thanks in advance for your time!
When the form is reset, what is the result of that calculation?
Is the result of that calculation used elsewhere?
Do you allow for no entires in TimeOut1 and TimeIn1 and other user entered fields?
George Kaiser