Firstly,
Many thanks for your response. It solved the problem and uncovered my mistake. Consequently I redisigned it to be a little more efficient and do away with an unnecessary variable. It works fine and is interactive. Pick a date get a date out and vice versa. I am now faced with a different problem arising from an add_days to a date routine that I picked up from the web.
(1) It reverses the days and months on my parsed out string and adds days to my months. enter dateIn 06/09/2007 and DateOut returns 09/06/2007
(2) In IE the year comes out correct say 2007 but in FF it's 107
Site in question
http://www.kohchangbookingandinformation.com/resorts_2.aspHere's the code
// date stuff
if(thisform.dateIn.value!=' ') {
thisform.dateOut.value = addDays(thisform.dateIn.value,parseInt(thisform.nightsNo.value));
}
function addDays(DIn,days) {
var numDaysToAdd = days
var daysInMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var start = new Date(DIn);
if (start != ' ') {
var y= start.getYear();
// check for leap year (see if year divided by four leaves a remainder). If it is a leap year, add one day to February
var remainder = y % 4;
if (remainder == 0) {
daysInMonth[1]=29;
}
var m = start.getMonth();
var x = start.getDate() + numDaysToAdd;
// check for roll over into next month, and then check that for roll into next year.
if (x > daysInMonth[m]){
x = x - daysInMonth[m];
m++;
if (m > 11){
m=0;
y++;
}
}
// increment month to real month, not "Array" month
m++;
if (x<10)
x="0"+x
if (m<10)
m="0"+m
var myDate = x+"/"+m+"/"+y;
return myDate ;
}
}
Once again thanks for your time and expertise. PS is there a datepicker that you can recommend that can do multiple calendars per page without a lot of hassle.
Robby