Hello,
I have this reservation form found on the main page of: http://www.avis.com.lb/
As you can see the current month "August" is selected as the default month and so is the year and day (the day is programmed to jump 2 days ahead for the renting of the car...)
However if you look closely (check the screenshot attached) you'll see that the month "August" is repeated twice and so is the year "2009", the current month is repeated twice. What I wanna do is remove the duplication and just auto select the current month without duplicating it.
I found this code: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_24229186.html
But it doesn't seem to work with my form, I donno why.
Here is the code of the script both javascript and a little bit of php
$date = strtotime("+2 day");
$date2 = date('j',$date);
$date4 = strtotime("+5 day");
$date3 = date('j',$date4);
if($date3 == 1){
$nextmonth = strtotime("+1 day");
$monthid = date('m',$nextmonth);
}else{
$nextmonth = strtotime("+0 day");
$monthid = date('m',$nextmonth);
}
if ($monthid==1){
$year = date("Y") + 1;
}else{
$year = date("Y");
}
//$pupday = date("j") - 12;
//$pupday = date("d") + 2;
//echo $pupday;
//$returnday = date("d") +5;
$month = date("F");
var xMonths = new Array( '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12' );
function getListValue( option_object ){return option_object[ option_object.selectedIndex ].value;}
function setListValue( option_object, value ){ option_object.selectedIndex = value;}
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}
function init()
{
xToday = new Date();
yToday = addDays(new Date(),3);
xMonth = xToday.getMonth();
xDay = xToday.getDate()-1;
xYear = xToday.getYear()-2005; if (xYear < 2005) xYear=0;
yMonth = yToday.getMonth();
yDay = yToday.getDate()-1;
yYear = yToday.getYear()-2005; if (yYear < 2005) yYear=0;
xF = document.forms['quickbooking'];
setListValue( xF.ETAHour, 9 )
setListValue( xF.ETAMonth, xMonth )
setListValue( xF.ETADay, xDay )
setListValue( xF.ETAYear, xYear )
setListValue( xF.ETTHour, 9 )
setListValue( xF.ETTMonth, yMonth )
setListValue( xF.ETTDay, yDay )
setListValue( xF.ETTYear, yYear )
}
<select class="formField" name="ETAMonth">
<option value="<? echo $monthid; ?>" selected="selected"><? echo $month; ?></option>
<option
value="01">January</option>
<option
value="02">February</option>
<option value="03">March</option>
<option
value="04">April</option>
<option value="05">May</option>
<option
value="06">June</option>
<option value="07">July</option>
<option
value="08">August</option>
<option value="09">September</option>
<option
value="10">October</option>
<option value="11">November</option>
<option
value="12">December</option>
</select>
<select
class="formField" name="ETAYear">
<option value="<? echo $year; ?>" selected="selected"><? echo $year; ?></option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select>
Help is very appreciated, thanks.