Forums / Developer / Date picker (pop-up)? / Comment45016
Fraser Hore
Tuesday 20 December 2005 1:21:26 pm
Ok, got it working. Went back to my old code and just replaced the variables with the ones from the name tag. One thing about the way mine is working now that i like is that i don't need a button. The calendar pops up no matter which field the user clicks in and and the updates all fields based on the selected date. Here's the code:
{literal} <script type="text/javascript"> function catcalc(cal) { var date = cal.date; var year = document.getElementById("{/literal}{$attribute_base}_date_year_{$attribute.id}{literal}"); year.value = date.print("%Y"); var month= document.getElementById("{/literal}{$attribute_base}_date_month_{$attribute.id}{literal}"); month.value = date.print("%m"); var day= document.getElementById("{/literal}{$attribute_base}_date_day_{$attribute.id}{literal}"); day.value = date.print("%d"); }; Calendar.setup( { inputField : "{/literal}{$attribute_base}_date_year_{$attribute.id}{literal}", ifFormat : "%Y", onUpdate: catcalc } ); Calendar.setup( { inputField : "{/literal}{$attribute_base}_date_month_{$attribute.id}{literal}", ifFormat : "%m", onUpdate: catcalc } );Calendar.setup( { inputField : "{/literal}{$attribute_base}_date_day_{$attribute.id}{literal}", ifFormat : "%d", onUpdate: catcalc } ); </script> {/literal}