DHTMLX Docs & Samples Explorer

onChangeMonth event handler

You can set an onchangemonth 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("onChangeMonth", mSelectMonth);
    mCal.draw();
 
}
function mSelectMonth(curMonth, prevMonth) {
    document.getElementById('mCalInput').innerHTML = 'Previous month # : ' + prevMonth + '<br /> Current month # ' + curMonth;
    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; border: 1px solid navy; height: 44px;padding: 3px;">&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.