Presetting the Highlighted Date in a Calendar on load

How do I send a VBScript date formatted variable in an .asp page to the calendar so that it highlights the variable date on opening and not the default “Today” date?

You may call setDate method. Please see details in the post:

viewtopic.php?f=7&t=16401

Dear Alexandra,

I am much obliged by your assistance so far but, regretfully, I have very little javascript experience so I’m not following you.

There are two calendars in my page. To set a “From” and “To” timezone for the data to be displayed. I want them to each have the date driven from the URL highlighted.

My parameters in the URL are mapped to VBSript variables “ShowFrom” and “ShowTo”.

How do I send those variables to the calendars in the format you provided in your earlier answer?

Where do I put the line
calendar.setDate(“15-Dec-2010”);?

What is the syntax when the date is the named variable and not a hard coded date as in the example provided?

Is it calendar.setDate("&ShowFrom&");

The link to the calendar looks like this in my .asp page:-

Again, thanks for your assistance so far.

Alan.

Hello,

cal1 = new dhtmlxCalendarObject('calInput1'); cal1 = new dhtmlxCalendarObject('calInput2');
Probably the last calendar needs being cal2 = new dhtmlxCalendarObject(‘calInput2’);

Where do I put the line

cal1 = new dhtmlxCalendarObject(‘calInput1’);
cal1.setDateFormat("%d-%b-%Y");
cal1.setDate(“15-Dec-2010”);

if the date is variable, you need to pass the JS variable ( not VBScript) into setDate method.

Dear Alexandra,

That was most helpful and I was able to find the remaining missing link about passing a variable from VBScript to Javascript on google and so the complete (and now working) code with a month/day/year format looks like this.

var ShowFrom='<%=ShowFrom%>' var ShowTo='<%=ShowTo%>' var cal1, cal2, mCal, mDCal, newStyleSheet; var dateFrom = null; var dateTo = null; window.onload = function() { cal1 = new dhtmlxCalendarObject('calInput1'); cal1.setDateFormat("%m-%d-%Y"); cal1.setDate(ShowFrom);
cal2 = new dhtmlxCalendarObject('calInput2');

cal2.setDateFormat("%m-%d-%Y");
cal2.setDate(ShowTo);
Alan. :smiley: