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

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;
}
        }

    );

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…


thank you for the remark. We’ll describe this feature in the documentation.