|
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: Tue Feb 15, 2005 7:20 pm Post subject: How to set the date range to start from today and end 7 days later? |
|
|
To set the range to start from today's date and prevent user from going to previous months, you need to change the gBegin option in the "theme-name".js file to be as following:
To set the range to end 7 days later after today and prevent user from going to future months, you need to change the gEnd option in the "theme-name".js file to be as following:
Code: | var _dEnd=new Date(gToday[0],gToday[1]-1,gToday[2]+7);
var gEnd=[_dEnd.getFullYear(),_dEnd.getMonth()+1,_dEnd.getDate()]; |
NOTE: The month number used in the javascript Date object is ranged from 0 to 11.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
por9xp
Joined: 29 Nov 2006 Posts: 3
|
Posted: Wed Nov 29, 2006 9:36 pm Post subject: Problem when start 2 days before today |
|
|
Hello:
I want to start 2 days before today, my code run ok in all days of the month but when in days 29, 30 and 31 not run.
Here is my code.
var _dBegin=new Date(gToday[0],gToday[1]-1,gToday[2]+2);
var gBegin=[_dBegin.getFullYear(),_dBegin.getMonth()+1,_dBegin.getDate()];
var gEnd=[2009,12,31];
Where is the problem?, I put an alert and the date is correct but the start calendary is placed in the final date (gEnd).
Thanks for all.
|
|
Back to top |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Thu Nov 30, 2006 12:02 am Post subject: |
|
|
Actually your code seems to set the range begin 2 days after today instead of before. To set it 2 days before today, you should use the following code instead:
Code: | var _dBegin=new Date(gToday[0],gToday[1]-1,gToday[2]-2);
var gBegin=[_dBegin.getFullYear(),_dBegin.getMonth()+1,_dBegin.getDate()]; |
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
por9xp
Joined: 29 Nov 2006 Posts: 3
|
Posted: Thu Nov 30, 2006 12:14 am Post subject: |
|
|
sorry about my english, I want to say 2 days after (sorry).
In the last days of each month the code not run ok and in the start calendary presents the month of the final date (gEnd).
what happens?
|
|
Back to top |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Thu Nov 30, 2006 3:16 am Post subject: |
|
|
Thank you for providing us the link. And here is a detailed explaination and solution. Please be patient while reading...
The problem is very specific when setting today+2 days as the start date based on the DateRange demo, which will result a starting date in the next month when today is at the end of previous month. e.g. if today is Nov 29 the starting date would have to be on Dec 1 - which would effectively disable all dates in the current month. However, the calendar would popup by default showing current month, so this would generate an unwelcomed calendar view with all days disabled unless the user move to the next month.
To avoid the above problem, there is a parameter called SafeMonth (detailed in hello world tutorial) that will take the calendar to the specified month if today's date is out of range.
The default implementation in the PopCalendarXP DateRange Demo uses the month of range end as the safe-month, which in your case caused the problem. To work around, you just need to change the parameter passed into the fPopCalendar() function to use gBegin as SafeMonth instead of gEnd, as following:
Code: | function fStartPop(startc,endc) {
_startc=startc;
_endc=endc;
var sd=fParseInput(endc.value);
if (!sd) sd=gEnd;
fPopCalendar(startc, [gBegin,sd,gBegin]);
} |
Note the only change we made is at the end of last line, comparing to the original one in plugins.js.
After this change your calendar should be working as expected.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
por9xp
Joined: 29 Nov 2006 Posts: 3
|
Posted: Thu Nov 30, 2006 9:55 am Post subject: |
|
|
Thanks a lot for your help!!
Now my calendars works fine!!
Best Regards.
|
|
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
|