DHTMLX Docs & Samples Explorer

onClick event handler

You can set an onclick event handler

 
attachEvent method sets function called when specified event occurs.
In case of onclick event a function incoming argument is the date of clicked day in the calendar.
Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxcalendar.css">
<script>
window.dhx_globalImgPath = "../../codebase/imgs/";
</script> <script src="../../codebase/dhtmlxcommon.js"></script> <script src="../../codebase/dhtmlxcalendar.js"></script> <script>
var mCal;
 
window.onload = function() {
    mCal = new dhtmlxCalendarObject('dhtmlxCalendar', false, {
        isYearEditable: true
    });
    mCal.attachEvent("onClick", mSelectDate);
    mCal.draw();
 
}
function mSelectDate(date) {
    document.getElementById('mCalInput').innerHTML = mCal.getFormatedDate("%d.%m.%Y", date);
    return true;
}
</script> <form action=""> <table > <tr> <td valign="top"><div id="dhtmlxCalendar"></div></td> </tr> <tr> <td colspan="2"><div id="mCalInput" style="color: navy; font-size:18px; font-family: Verdana; text-align:center; border: 1px solid navy">&nbsp;</div></td> </tr> </table> </form> <b>attachEvent</b> method sets function called when specified event occurs.<br> In case of onclick event a function incoming argument is the date of clicked day in the calendar.