The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Date Time Picker customization

shill
Mega Sage

From a request we had by the process owners of change, we developed a onLoad client script to set the DateTime picker to default to zeros on the time entry so when the icon is clicked, the time is defaulted to 00:00:00 in the popup.

Here is our current code


function onLoad() {
     setDatePickerTime('start_date');
     setDatePickerTime('end_date');
     setDatePickerTime('requested_by_date');
     setDatePickerTime('work_start');
     setDatePickerTime('work_end');
   
function setDatePickerTime(field){
     //Attach an event listener to set default time value for date picker
     Event.observe(g_form.getControl(field).next('a'), 'click', function() {
           $('GwtDateTimePicker_hh').value = '00';
           $('GwtDateTimePicker_mm').value = '00';
           $('GwtDateTimePicker_ss').value = '00';
     });
}   
}


Works fine in Aspen, but not in Berlin. We are getting java errors in IE and although we do not get errors in Chrome/Firefox, it does not change the time entries to zeros.
Does anyone have any ideas what changes I might make to allow this to work again in Berlin?
17 REPLIES 17

Thanks Shannon! Just the solution I was looking for. Much appreciated!


This worked perfect, but why do we need to set the value 300 and remove 'a' from the script?



Thanks


Divya


andrewgamble
Tera Contributor

Please forgive me, as I'm still very new at scripting but I have a couple questions...



1.   Is it possible to set the Date Picker Time for two different fields to two separate times on the same form?   For example, have a start time of 16:00:00 and and end time of 18:00:00.   I tried using two client scripts with the different field but the second script overrode the first one.



2.   How can you keep from changing the time value on records that already have a date/time selected.   Whenever I clicked the Date Picker icon, the time always reverted back to whatever was selected in the script instead of the time that was already in the field.   I think this should be done through some type of if statement but I'm not sure how to format it.



Thanks,


Andrew