Copy link to clipboard
Copied
I have a manually entered time field h:MM tt but I want it to populate another field but deducting 1.5 hours.
Example: "Day1startTime" is 8:00 am, minus 1.5 hours should autopopulate "Day1arrivalTime" 6:30am
Can someone please help me!
Copy link to clipboard
Copied
Here's one technique that uses the date object.
This code is for a custom valdate script on the "Day1startTime" field, where the time value is entered.
var strArrTime = "";
var oTimeNow = util.scand("dd/mm/yy h:MM tt","01/01/23 " + event.value);
if(oTimeNow && !isNaN(oTimeNow.getTime()))
{
oTimeNow.setMinutes(oTimeNow.getMinutes() - 90);
strArrTime = util.printd("h:MM tt",oTimeNow);
}
this.getField("Day1arrivalTime").value = strArrTime;
Copy link to clipboard
Copied
Thank you so much! That worked perfectly!
Copy link to clipboard
Copied
Could you help me with one more thing?
Is it possible that the "Day1ArrivalTime" shows blank if there is no time in the Day1startTime? Right now if I don't enter a time the Arrival time automatically shows 10:30pm. (I guess it assumes that no entry on Day1start time is midnight).
Thanks again!
Copy link to clipboard
Copied
Use this:
if (event.value=="") this.getField("Day1arrivalTime").value = "";
else {
// put Thom's code here
}