noahd1
Newbie
Posts: 1
Registered: 9/24/2003
Member Is Offline
|
| posted on 9/24/2003 at 10:05 AM |
|
|
no past dates allowed
I updated the calendar so that a user cannot select dates in the past. Note that it doesn't take into account time at all, b/c my application
didn't need that.
To do this, I made a few changes:
1. in calender2.js, i made a new property for the calendar object called "past_dates". You can set it to true/false on the calling page just
like you do with year scrolling and time_comp.
2. in calendar.html, I check the value of the "past_dates" property, and if it's false, then I do not print the previous month scroll
(if it's the current month), and I do not print out the link for days in the past (the day is still there obviously, but it's just not
linked)
Here's a relevant chunk of code from calender.html
One important piece not shown is where i "zero-out" the time component of today's date so that the date arithmatic shown below works
out right.
| Code: |
// if it's today or a future date allow it to be selected
if ((obj_caller && obj_caller.past_dates) || dt_current_day - dt_today >= 0)
document.write('<a href="javascript:set_datetime('+dt_current_day.valueOf() +', true);">');
if (dt_current_day.getMonth() == this.dt_current.getMonth())
// print days of current month
document.write('<font color="#000000">');
else
// print days of other months
document.write('<font color="#606060">');
document.write(dt_current_day.getDate()+'</font>');
if ((obj_caller && obj_caller.past_dates) || dt_current_day - dt_today >= 0)
document.write('</a>');
document.write('</td>');
|
Hope this helps someone. It could use some work but it's a start.
|
|
|
webtech
Junior Member
Posts: 2
Registered: 1/31/2005
Member Is Offline
|
| posted on 1/31/2005 at 07:29 AM |
|
|
i am a new guy on this.
would you please provide full update information.
Full sample code is better.
Thank you!
|
|
|
webtech
Junior Member
Posts: 2
Registered: 1/31/2005
Member Is Offline
|
| posted on 2/17/2005 at 05:53 AM |
|
|
i use the following code in calendar.html,but the past dates still allowed to be selectd(it's linked).
Please help.
// print weekdays titles
for (var n=0; n<7; n++)
document.write('<td bgcolor="#87cefa" align="center"><font
color="#ffffff">'+ARR_WEEKDAYS[(NUM_WEEKSTART+n)%7]+'</font></td>');
document.write('</tr>');
// print calendar table
var dt_current_day = new Date(dt_firstday);
while (dt_current_day.getMonth() == dt_current.getMonth() ||
dt_current_day.getMonth() == dt_firstday.getMonth()) {
// print row heder
document.write('<tr>');
for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
if (dt_current_day.getDate() == dt_current.getDate() &&
dt_current_day.getMonth() == dt_current.getMonth())
// print current date
document.write('<td bgcolor="#ffb6c1" align="center" width="14%">');
else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
// weekend days
document.write('<td bgcolor="#dbeaf5" align="center" width="14%">');
else
// print working days of current month
document.write('<td bgcolor="#ffffff" align="center" width="14%">');
// if it's today or a future date allow it to be selected
if ((obj_caller && obj_caller.past_dates) || dt_current_day - dt_today >= 0)
document.write('<a href="javascript:set_datetime('+dt_current_day.valueOf() +', true);">');
if (dt_current_day.getMonth() == this.dt_current.getMonth())
// print days of current month
document.write('<font color="#000000" style="text-decoration: none">');
else
// print days of other months
document.write('<font color="#606060" style="text-decoration: none">');
document.write(dt_current_day.getDate()+'</font>');
if ((obj_caller && obj_caller.past_dates) || dt_current_day - dt_today >= 0)
document.write('</a>');
document.write('</td>');
dt_current_day.setDate(dt_current_day.getDate()+1);
}
// print row footer
document.write('</tr>');
}
|
|
|