Forums / Developer / Date picker (pop-up)? / Comment45014
Paul Forsyth
Tuesday 20 December 2005 8:33:16 am
Ok, i have it working now.
Once you have it all setup try this code:
<button type="reset" id="{concat('trigger',$attribute.id)}">...</button> {literal} <script type="text/javascript"> Calendar.setup( { onSelect : onSelectDateTime{/literal}{$attribute.id}{literal}, button : "trigger{/literal}{$attribute.id}{literal}" } ); function onSelectDateTime{/literal}{$attribute.id}{literal}(calendar, date) { var year= document.getElementById("{/literal}{$attribute_base}_datetime_year_{$attribute.id}{literal}"); var month= document.getElementById("{/literal}{$attribute_base}_datetime_month_{$attribute.id}{literal}"); var day= document.getElementById("{/literal}{$attribute_base}_datetime_day_{$attribute.id}{literal}"); var date_array=date.split("/"); year.value=date_array[0]; month.value=date_array[1]; day.value=date_array[2]; if (calendar.dateClicked) { calendar.callCloseHandler(); // this calls "onClose" (see above) } }; </script> {/literal}
In this case im using datetime template though the code works for both.
One thing you have to adjust is the id tag for each input tag. You *must* copy the name param to an id param or the system wont be able to retreive the field and getElementByID will fail. Kristian, i dont suppose these id tags could be added to the template(s)?
I have this working in an extension but the design.ini file is doint what it should. I've added [StylesheetSettings] and [JavaScriptSettings] but when ezdesign operator is applied it simply doesnt find it. 'ezdesign' does look inside the extensions so im puzzled about this. I resorted to putting hardcoded script lines in pagelayout. You *cannot* put script lines to include the js files into the attribute tpl file. If you have more than one attribute the script will be included more than once and cause problems.
Hope this helps!
Paul