Hi,
I'm trying to pre-fill the date & time for a date/time control on my form by using a button on my form. I don't want to use a default column value and I want the user to be able to pre-fill the field on a per-case basis.
What I've done so far is:
- Created a button on the form, with the action of 'JavaScript'
- Given the date/time control a Client ID
- Created the following function within the 'Custom JavaScript' section in Form Settings:
function setDateTime()
{
var fullDate = new Date()
var twoDigitMonth = ("0" + (fullDate.getMonth() + 1)).slice(-2)
var hours = fullDate.getHours();
var minutes = fullDate.getMinutes();
var currentDate = fullDate.getDate() + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
if (hours < 10) { hours = "0" + hours; }
/** Round down to the nearest 5 minutes. This is due to us rounding the minutes but not the hours. For example, 09:58 could be rounded up to 09:60 (invalid). Instead, 09:58 becomes 09:55.
**/
minutes = minutes - 2.5;
minutes = 5 * Math.round( minutes / 5 );
// Set the date field
NWF$('#' + fldDateClosed).val(currentDate);
// Set the time (hours + minutes) fields
NWF$('#' + fldDateClosed + ' + IMG + SELECT').val(hours);
NWF$('#' + fldDateClosed + ' + IMG + SELECT + SELECT').val(minutes);
// Set Incident Status
NWF$('#' + fldStatus).val('Completed');
}
Upon previewing, and clicking the 'Now' button on the form, it fills the input with the following:
Does anyone have any ideas as to how I can modify the hours and minutes on the form?
Thanks