View Full Version : Jason's Date Input Calendar

11-30-2008, 09:52 PM
1) Script Title: Jason's Date Input Calendar

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm

3) Describe problem: I've been using this script for a long time and it is brilliant. There is just one refinement I would like to include, but I'm getting nowhere trying to work it out for myself.

I use the script on a hotel booking form so there are two inputs on the same same form: Arrival Date and Departure Date. It is currently set up with the default which shows the current date, until the user changes it. Unfortunately, a significant number of users fill in the departure date incorrectly because they don't change the month.

For instance, if today is 1 Jan 2009, that is what shows in both fields when the page first comes up. The user then changes the arrival date to 3 Feb 2009 and wants to stay at the hotel for a week. They then go to the departure date and change the day to "10", which then gives the departure date as 10 Jan 2009. Wrong!

I would like to make the script operate so that once the arrival date is filled in, the departure date changes from current date to arrival date. I've tried various ideas but being a javascript numpty, I haven't yet made it work. Any ideas, anyone?

11-30-2008, 10:53 PM
Could you post the code you have now, or a link to the site?

12-01-2008, 08:30 AM
I should have thought of that!

The script is bog standard Jason's calendar. It's at http://www.littlehotels.co.uk/js/arDateInput.js. An example of the form is http://www.littlehotels.co.uk/enquiryform.php.

The crucial bit of the enquiry form page (starting at line 301) is:

<tr class="formleft">
<td>Arrival Date</td>
<script>DateInput('ArrDate', true, 'YYYY-MM-DD')</script>
<tr class="formleft">
<td valign="top">Departure Date</td>
<script>DateInput('DepDate', true, 'YYYY-MM-DD')</script>
&nbsp;<span class="formnote">&nbsp;(The morning you will check out) </span></td>

I don't use the fourth argument in DateInput at the moment so it defaults to current date. I assume that I probably need to make the fourth argument of DepDate show a string version of ArrDate, and then use something like onBlur or onMouseUp to make the script re-run after ArrDate has been filled in. I've tried all sorts of things, but I just haven't been able to make it work.

Thanks for your assistance.

12-01-2008, 12:48 PM
Your js link doesn't work, do you mean this one:


12-01-2008, 12:56 PM
Yes, that's the one. I didn't spot the typo in my last post.