We have developed a custom module for appointment. We need to get date of the appointment. We have added the below code in my custom page xml and phtml files
In XML file:
<reference name="head">
<action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params></params></action>
<action method="addItem"><type>js</type><name>calendar/calendar.js</name><params></params></action>
<action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><params></params></action>
<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
</reference>
In phtml file:
<input name="dob" id="_dob" value="" type="text">
<img title="Select date" id="_dob_trig" src="<?php echo $this->getSkinUrl('images/calendar.gif')?>" class="v-middle">
and in footer section of the page:
<script type="text/javascript">
//<![CDATA[
Calendar.setup({
inputField : '_dob',
ifFormat : '%m/%e/%y',
button : '_dob_trig',
align : 'Bl',
singleClick : true
});
//]]>
</script>
There is no JavaScript error, but calendar window does not open while clicking the calendar icon.
What I'm missing? Please help.
Best Answer
When I try your code I get a JS error:
If I add all of the initialization that goes along with the calendar above the footer calendar
<script>
then it works.