Categories | Question details Back To List | ||
Double Calendar onClick date source I need to set a text field and a hidden field for each calendar in a double calendar. I am using the following: mDCal.setOnClickHandler(function(){ document.getElementById("label-arrive").innerHTML = mDCal.leftCalendar.getFormatedDate(); document.getElementById("group_arrive_on").value = mDCal.leftCalendar.getFormatedDate(); document.getElementById("label-depart").innerHTML = mDCal.rightCalendar.getFormatedDate(); document.getElementById("group_depart_on").value = mDCal.rightCalendar.getFormatedDate(); } ); The problem is that the setOnClickHandler fires before the date is actually set so getFormattedDate() does not pull the correct date. I tried to pass the date into the function like this: mDCal.setOnClickHandler(function(date){ document.getElementById("label-arrive").innerHTML = date; document.getElementById("group_arrive_on").value = date; document.getElementById("label-depart").innerHTML = date; document.getElementById("group_depart_on").value = date; } ); But it sets both dates the same on a left calendar or right calendar click. How do I know which calendar 'date' is coming from? Thanks, Greg Answer posted by Support on May 20, 2008 07:51 The onclick handler sends 3 parameters a) date object b) pointer to the calendar instance c) "right" or "left" value mDCal.setOnClickHandler(function(date,cal,type){ if (type=="left"){ document.getElementById("label-arrive").innerHTML = date; document.getElementById("group_arrive_on").value = date; } else { document.getElementById("label-depart").innerHTML = date; document.getElementById("group_depart_on").value = date; } } ); Answer posted by JanM on Aug 04, 2009 06:21 Nice! I searched for exactely this answer for more than an half hour, it would be nice if you can discribe this feature in the official documentation... Answer posted by Alex (support) on Aug 04, 2009 07:28 thank you for the remark. We'll describe this feature in the documentation. |