Re[2]: JSCalendar in AJAX Page
2008/10/06 18:20
Viewed 3419 times
Replies: 1/2
by J_B

I got around the "side-effect" (having to click twice for the calendar to appear) by implementing this slightly differently, and adding a bit of code to dispatch a second click event to the element that triggers the pop-up calendar:

<input type='text' id='date' name='date' style='text-align: center;' size='10' maxlength='10' value='$date' onClick='calSetup_date(this)' readonly>
<script type="text/javascript">
function calSetup_date_$row(element)
{
Calendar.setup(
{
align : "br", // align to cover input field
inputField : "date", // ID of the input field
ifFormat : "%Y-%m-%d", // the date format
weekNumbers : false, // Don't display week numbers
step : 1, // year step in menu
}
);
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
element.dispatchEvent(evt);
}
</script>

Google