Ahh, when I went to update the post it erased the first post....
I am using a date picker on a form for webervations and I need to know how to get the date into the necessary format of "zday", "zmonth" and "zyear". Form code is below:
<div class="cellform">Arrival date</div>
<form method="post" action="http://www.webervations.com/magic-scripts/resbook.asp" target="_blank" name="form1" id="room-reservation-form">
<div class="cellform">
<input id="datepicker_1" name="Date" type="text" />
</div>
<div class="cellform">Nights?</div>
<div class="cellform">
<select name="zlength">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
</select></div>
<input type="hidden" name="zday" id="zday" value="" />
<input type="hidden" name="zmonth" id="zmonth" value="" />
<input type="hidden" name="zyear" id="zyear" value="" />
<input type="hidden" name="showit" value="Y">
<input type="hidden" name="cbp" value="">
<input type="hidden" name="zcaller" value="xxx">
<input type="hidden" name="memberid" value="xxx">
<div class="cellform"><input name="Submit" value="Check Availability" type="submit"></div>
Here is the related javascripts:
</script>
<link type="text/css" href="webassist/datepicker/about_datepicker_1/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="webassist/jquery/jquery.js"></script>
<script type="text/javascript" src="webassist/jquery/jquery-ui.js"></script>
<script type="text/javascript">
$(function(){
$('#datepicker_1').datepicker({
dateFormat: 'mm/dd/yy',
showAnim: 'fade',
onClose: closeDatePicker_datepicker_1
});
});
function closeDatePicker_datepicker_1() {
var tElm = $('#datepicker_1');
if (typeof datepicker_1_Spry != null && typeof datepicker_1_Spry != "undefined" && Date_Spry.validate) {
datepicker_1_Spry.validate();
}
var docElm = document.getElementById("datepicker_1");
var tBlur = docElm.getAttribute("onBlur");
if (!tBlur) tBlur = docElm.getAttribute("onblur");
if (!tBlur) tBlur = docElm.getAttribute("ONBLUR");
if (tBlur) {
tBlur = String(tBlur).replace(/\bthis\b/g, "docElm");
eval(tBlur);
}
}
</script>
<script type="text/javascript">
//Current date in form script
//By Lee Hinder (lee.hinder@ntlworld.com)
//Visit http://javascriptkit.com for this script and more
//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape
//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
var DaysInMonth = 31;
if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))
DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))
DaysInMonth = 29;
return DaysInMonth;
}
//function to change the available days in a months
function ChangeOptionDays(Which)
{
DaysObject = eval("document.Form1." + "zday");
MonthObject = eval("document.Form1." + "zmonth");
YearObject = eval("document.Form1." + "zyear");
Month = MonthObject[MonthObject.selectedIndex].text;
Year = YearObject[YearObject.selectedIndex].text;
DaysForThisSelection = DaysInMonth(Month, Year);
CurrentDaysInSelection = DaysObject.length;
if (CurrentDaysInSelection > DaysForThisSelection)
{
for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
{
DaysObject.options[DaysObject.options.length - 1] = null
}
}
if (DaysForThisSelection > CurrentDaysInSelection)
{
for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
{
NewOption = new Option(DaysObject.options.length + 1);
DaysObject.add(NewOption);
}
}
if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}
//function to set options to today
function SetToToday(Which)
{
DaysObject = eval("document.Form1." + "zday");
MonthObject = eval("document.Form1." + "zmonth");
YearObject = eval("document.Form1." + "zyear");
YearObject[0].selected = true;
MonthObject[NowMonth].selected = true;
ChangeOptionDays(Which);
DaysObject[NowDay-1].selected = true;
}
//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
line = "";
for (i=0; i<YearsAhead; i++)
{
line += "<OPTION>";
line += NowYear + i;
}
return line;
}
</script>