Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

onchange event not working for ui_date field type in UI Page?

agulati
Kilo Expert

onchange event not working for ui_date field type in UI Page but it works for   ui_date_time field type.

Any suggestions?

1 ACCEPTED SOLUTION

Hi, Aman. The ui_date UI Macro does not add the onchange attribute to the input element. If you check the macro you'll see this:



            <input id="${jvar_name}" type="text" name="${jvar_name}" value="${jvar_value}" />



It's easy enough to add it like this:



            <input id="${jvar_name}" type="text" name="${jvar_name}" value="${jvar_value}" onchange="${jvar_onchange}" />



But rather than modify the delivered version you should create a copy of ui_date (called ui_date_custom ??) and change that macro to include the onchange attribute.



Then in your ui page call your custom ui macro like this:


  <g:inline template="ui_date_custom" name="start_date_row1" id="start_date_row1" value = "" onchange="datePicked(this.value,'oncall_end_date_row1');"/>



Hope that helps.



- Steve


View solution in original post

5 REPLIES 5

Sanjeev Kumar1
Kilo Sage

Hi,


Please post your code and UI Page which you are using.


Thanks,


agulati
Kilo Expert

Hi,



Below is the line of code that i have in the UI Page



<g:ui_date name="start_date_row1" id="start_date_row1" value = "" onchange="datePicked(this.value,'oncall_end_date_row1');"/>




When i look at the source of resulting html, i see



<label style="display:none" for="start_date_row1">start_date_row1</label>


<input id="start_date_row1" value="" name="start_date_row1" type="text">


<span style="margin: 2px"></span>


<a onclick="new GwtDateTimePicker('start_date_row1', 'yyyy-MM-dd', false);"><img id="anchorstart_date_row1x" title="Choose date..." name="anchorstart_date_row1x" class="button" src="images/small_calendar.gifx" border="0" height="16" width="16"></a>



I dont even see the onchange event in the html. If i change the widget type to ui_date_time , i do see the onchange code



Thanks


Hi, Aman. The ui_date UI Macro does not add the onchange attribute to the input element. If you check the macro you'll see this:



            <input id="${jvar_name}" type="text" name="${jvar_name}" value="${jvar_value}" />



It's easy enough to add it like this:



            <input id="${jvar_name}" type="text" name="${jvar_name}" value="${jvar_value}" onchange="${jvar_onchange}" />



But rather than modify the delivered version you should create a copy of ui_date (called ui_date_custom ??) and change that macro to include the onchange attribute.



Then in your ui page call your custom ui macro like this:


  <g:inline template="ui_date_custom" name="start_date_row1" id="start_date_row1" value = "" onchange="datePicked(this.value,'oncall_end_date_row1');"/>



Hope that helps.



- Steve


Thanks Steve.


This works perfectly.