calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Fri Dec 30, 2005 11:43 pm Post subject: How to select multiple dates, say 2 weeks including the clicked date? |
|
|
There is a call-back function in the plugins.js called fIsSelected(y,m,d), which determines whether to mark the passed-in date as a selected date.
If this function returns true, the specific date passed in will be marked as selected using theme options giMarkSelected, gcFGSelected, gcBGSelected and guSelectedBGImg.
To select multiple dates, you just need to create an array in the plugins.js to store either the selected dates or the selected date range. This array may get assigned via fOnChange() or fAfterSelected() plugin, then being checked from within the fIsSelected().
e.g. put the following code in plugins.js. The selected dates will be stored in the _duration array in the container HTML (you may add more code to fAfterSelect() to parse the array into a hidden form field so that it can be submitted to the server):
Code: | var _durationDays=14;
function fAfterSelected(y,m,d,e) {
var dt=new Date(y, m-1, d);
if (!gContainer._duration)
gContainer._duration=[];
for (var i=0; i<_durationDays; i++) {
gContainer._duration[i]=[dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
dt.setDate(dt.getDate()+1);
}
fRepaint(); // refresh the panel
}
function fIsSelected(y,m,d) {
if (!gContainer._duration) return false;
var dur=gContainer._duration;
for (var i=0; i<dur.length; i++) {
if (y==dur[i][0]&&m==dur[i][1]&&d==dur[i][2])
return true;
}
return false;
} |
You may find other examples in the MultiPicker demo in FlatCalendarXP or the WeekPicker demo in PopCalendarXP.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|