|
CalendarXP.net Support Most forums here are private and invisible to public.
|
View previous topic :: View next topic |
Author |
Message |
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Sun Aug 28, 2005 3:43 pm Post subject: [PopCalendarXP]How to restrict the range of ending date by the starting date? |
|
|
In the date range demo, the ending date is only restricted at one end - no earlier than the starting date. To restricted it on both end, e.g. ending date should be no earlier than the starting date and no later than 40 days after the starting date, you just need to modify the fEndPop() in the plugins.js as following:
Code: | function fEndPop(startc,endc) {
_startc=startc;
_endc=endc;
var sd=fParseInput(startc.value);
if (!sd) sd=gBegin;
var dt = new Date(sd[0], sd[1]-1, sd[2]+40);
var ed = [dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
fPopCalendar(endc, [sd,ed,sd]);
} |
Note the new dt and ed variables we added here to calculate the ending range and pass into the fPopCalendar() call. And in the same way you can also change the starting range of the ending date to be 1 day after the starting date, e.g.
Code: | function fEndPop(startc,endc) {
_startc=startc;
_endc=endc;
var sd=fParseInput(startc.value);
if (!sd) sd=gBegin;
var dt = new Date(sd[0], sd[1]-1, sd[2]+1);
var eds = [dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
dt = new Date(sd[0], sd[1]-1, sd[2]+40);
var ed = [dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
fPopCalendar(endc, [eds,ed,eds]);
} |
Please refer to the HelloWorld beginner tutorial on how to use the 2nd parameter of fPopCalendar() to dynamically restrict the selectable date range.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
tspcenter
Joined: 25 Jul 2008 Posts: 4
|
Posted: Sat Jul 26, 2008 3:36 pm Post subject: |
|
|
This works great, however I found that that the second code sample ignores gEnd and allows selectable dates beyond gEnd if the new ending range exceeds it.
Is there a way for gEnd to be evaluated and set the new ending range to gEnd if var dt exceeds it?
Thank you.
|
|
Back to top |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Sun Jul 27, 2008 12:12 am Post subject: |
|
|
Yes, it's quite easy by adding another check in the fEndPop() function, as following:
Code: | function fEndPop(startc,endc) {
_startc=startc;
_endc=endc;
var sd=fParseInput(startc.value);
if (!sd) sd=gBegin;
var dt = new Date(sd[0], sd[1]-1, sd[2]+1);
var eds = [dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
dt = new Date(sd[0], sd[1]-1, sd[2]+40);
var ed= (dt>gdEnd) ? gEnd : [dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
fPopCalendar(endc, [eds,ed,eds]);
} |
Note that gdEnd is the Date representation of gEnd, which is an array for easy configuration.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
tspcenter
Joined: 25 Jul 2008 Posts: 4
|
Posted: Sun Jul 27, 2008 5:58 pm Post subject: |
|
|
Thank you for your prompt response and modified code example.
I must say that your calendar software has been very easy to work with. I've been able to configure it or modify plugins.js to handle all the unique requirements specific to my application.
I'm glad I puchased it.
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group
|