Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Gaizka on Mar 01, 2009 23:07
open dhtmlx forum
Multiple calendars on one page

I have multiple calendars on one page but if I make a "new dhtmlxCalendarObject" for everyone the page, especially in IE, loads very slowly. Can I have just one calendar and use it for every input text?

Thanks,
Gaizka
Answer posted by Support on Mar 02, 2009 06:29
Sure, but in such case you will need to use a custom code to show|hide calendar. Something similar to next 

        mCal = new dhtmlxCalendarObject('dhtmlxCalendar');
        mCal.setYearsRange(2000, 2500);
        mCal.draw();
        mCal.hide();

document.getElementById("some_input").onclick=show_calendar;

function show_calendar(){
    var input = this;

    mCal.setFormatedDate(input.value);
    mCal.show();
    mCal.setOnClickHandler(function(){
        input.value = mCal.getFormatedDate();
        mCal.hide();
        return true;
    });
}

Answer posted on Mar 02, 2009 22:17
The calendar must appear near every input so i've to position it, no?
Answer posted by Alex (support) on Mar 03, 2009 03:03

The calendar can be easily attached to the necessary input:

mCal.setPosition(input);

Where input is the object of the html input