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

yes, will you paste your code so I can look it over?


hi,



trying as below



function setDatePickerTime(field){


//Attach an event listener to set default time value for date picker


var linkElement = $(g_form.getControl(field).id).next();


if (linkElement !== undefined) {


alert(linkElement);


Event.observe($(g_form.getControl(field).id).next(), 'click', function() {             setTimeout("$('GwtDateTimePicker_hh').value = '00';$('GwtDateTimePicker_mm').value = '00';$('GwtDateTimePicker_ss').value = '00';",300);     });


}


}


Here is what I'm using.



This is an onload client script.



function setDatePickerTime(field, hour){


      if(g_form.getValue(field)!=''){


              return;


      }


     


    //Attach an event listener to set default time value for date picker


    Event.observe($(g_form.getControl(field).id).next(), 'click', function() {


          setTimeout("$('GwtDateTimePicker_hh').value = " + hour +";$('GwtDateTimePicker_mm').value = '00';$('GwtDateTimePicker_ss').value = '00';",300);


    });


   


}


Hi Shannon,



I tried this as well but it is still not working, I forgot to mention that i am trying this in scoped application.



Please let me know if you can help me on this.



Regards,


Girish Deshpande


Hi Girish,



I saw a post on a website a few weeks ago about scoped apps not having access to the DOM.   I can't seem to find that post anymore, otherwise I would refer you to it.   I'm pretty sure that is the problem you are running into.   When I get some time, I will test it out in a scoped app and see if I can make it work.



Shannon