CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[PopCalendarXP]How to restrict the range of ending date by the starting date?

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q.
View previous topic :: View next topic  
Author Message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Sun Aug 28, 2005 3:43 pm    Post subject: [PopCalendarXP]How to restrict the range of ending date by the starting date? Reply with quote

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
View user's profile Send private message
tspcenter



Joined: 25 Jul 2008
Posts: 4

PostPosted: Sat Jul 26, 2008 3:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Sun Jul 27, 2008 12:12 am    Post subject: Reply with quote

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
View user's profile Send private message
tspcenter



Joined: 25 Jul 2008
Posts: 4

PostPosted: Sun Jul 27, 2008 5:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
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