View Full Version : Script: Popup Calendar | Doesn't work consistently with multiple fields
09-23-2004, 12:57 PM
Script: Popup Calendar
Problem: This script doesn't appear to work consistently when applying it to multiple input fields on a page. In this scenario it will return a date that was NOT selected by the user.
Example: (Assuming a MM/DD/YYYY format) I have two input text fields on a page that allow the user to select a "START DATE" and an "END DATE" using the Popup Calendar script. If I select 8/31/2004 as the "START DATE" and then select 9/10/2004 as the "END DATE", I am instead returned the value of 10/10/2004 as the "END DATE" instead of what I actually selected.
I have setup the script exactly as specified and it appears to work when using on only one field. It only appears to err when it is applied to multiple fields on a page.
Is this a bug? A configuration issue? Or was this script not intended to work with more than one field?
I would appreciate any feedback on this issue.
09-23-2004, 04:26 PM
Give different names for both input. And then refer to the correct name on the onClick event.. example :
<input type="text" name="start">
<input type="text" name="end">
Hope that'll work... It works fine in My computer :)
09-23-2004, 06:14 PM
Thanks for the reply, gigabytes.
I plugged in your code (which is almost identical to mine), but unfortunately I am still encountering this problem.
Did you test with the dates I provided in my previous post? This bug only appears to rear its head with certain date combinations.
To recreate the bug, use these dates: Select a start date of 8/31/2004 using the popup calendar, and then select an end date of 9/10/2004. The end date will be returned as 10/10/2004 instead of 9/10/2004. I have been able to consistently recreate this error using these specific dates.
If you have a moment, could you attempt to recreate this error using the dates I provided? Thanks!
Leon (aka Bizwax)
09-23-2004, 07:31 PM
Hmm.. Nope.. the dates are correct... I can't use past dates for start date though... I set My clock a month back and run the script and it shows me the right date.
Maybe You previously changed the script's core and forgot about it... :p Try to modify the script right from the very begining and see if it still shows You the wrong date...
09-23-2004, 07:45 PM
OK, I have found that this bug can be consistently recreated using other dates as well as the ones I initially provided, and this bug has more problems than just returning an incorrect date.
In addition to this bug returning an erroneous date, the Popup Calendar also displays an incorrect calendar under certain circumstances. When displaying an erroneous calendar, it will label the calendar with the user's selected month name (i.e. September), but the calendar will in actuality be showing dates for the following month (i.e. October).
In my scenario using the START DATE and END DATE fields, the following must be present to recreate the error:
* The user's selected END DATE must be within the month consecutively after the user's selected START DATE. (Example: Start = 8/31/2004, End = 9/10/2004)
* The user's selected START DATE MONTH must have more calendar days in it than the user's selected END DATE MONTH. (Example: August has 31 days, while September only has 30.)
* The user's selected START DATE must be a date not available in the END DATE MONTH. (Example: The 31st is a date in August, yet September does not have a 31st.)
But you can also recreate these errors using ONLY ONE input field, so this bug has nothing to do with using multiple fields as I had previously assumed. You can apply the term "START DATE" to mean "FIRST DATE SELECTION" and the term "END DATE" to mean "SECOND DATE SELECTION" when using only one input field.
To recreate this error using only ONE field:
1. Click on the link to open the Popup Calendar, and then select the date of 10/31/2004.
2. Click on the same link to open the Popup Calendar again and forward the calendar to the month of November 2004.
3. At this point the calendar will be labeled as "November 2004", but it will show the dates of November 2004.
4. Select any date on this erroneous calendar and it will return a December date (12/X/2004), not a November date (11/X/2004)
So to consistently recreate these errors, select ANY the following dates first as your "FIRST DATE SELECTION", and then immediately afterwards select any date from the month consecutively following your initial selection as your "SECOND DATE SELECTION":
Jan 30,31 (select the following date from Feb)
March 31 (select the following date from Apr)
May 31 (select the following date from June)
Aug 31 (select the following date from Sep)
Oct 31 (select the following date from Nov)
I have tracked this error down to the ppcPtr.setMonth(month) call in setCalendar(). I am looking into a fix for this item.
Leon (aka Bizwax)
09-23-2004, 07:51 PM
Typo... Should be...
3. At this point the calendar will be labeled as "November 2004", but it will show the dates of December 2004.
09-23-2004, 08:14 PM
To fix this bug, swap the following statements within pupdate.js in the setCalendar() procedure:
As long as this script has been out, I am surprised no one has ever caught wind of this bug.
Do you have any other scripts that need debugging? $end them my way! ;)
Leon (aka Bizwax)
09-23-2004, 08:30 PM
Oh Yes... You're right.. I do get the same error when selecting the last date of a 31-day month, and the reselect it to any day of a 30-day month...
Bravo Leon... Hurraayyy... :D
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.