I have a page for car rentals where the client enters the desired pickup and drop-off dates. If the pickup date is near the end of the year and the drop off date is the next year, I am trying to get the year to change automatically so that they cannot inadvertently enter something like this:

Pickup: 12/25/2010
Drop-off: 1/7/2010

Not sure how to do it without changing the date in both year boxes. Here is the code as it is right now:

Code:
// Fill Option Year Box 1
$lowyear = date("Y"); $highyear = date("Y")+1;
$yearfill = "<select name='Pick_Year' class='ckform' size='1' onChange='Pi_Year()'>\n";
for($n=$lowyear; $n <=$highyear; $n++) {
   if ($n == $year1) {
      $yearfill.= "<option value='$n' selected>$n</option>\n";
   } else {
      $yearfill.= "<option value='$n'>$n</option>\n";   
   }   
}
$yearfill.= "</select>";

// Fill Option Day Box 1
$dayfill = "<select name='Pick_Day' class='ckform' size='1' onChange='Pi_Day()'>\n";
for($n=1; $n <=31; $n++) {
   if ($n == $day1) {
      $dayfill.= "<option value='$n' selected>$n</option>\n";
   } else {
      $dayfill.= "<option value='$n'>$n</option>\n";   
   }   
}
$dayfill.= "</select>";

// Fill Option Month Box
$SMonth[1]  = "January";
$SMonth[2]  = "February";
$SMonth[3]  = "March";
$SMonth[4]  = "April";
$SMonth[5]  = "May";
$SMonth[6]  = "June";
$SMonth[7]  = "July";
$SMonth[8]  = "August";
$SMonth[9]  = "September";
$SMonth[10] = "October";
$SMonth[11] = "November";
$SMonth[12] = "December";

$monthfill = "<select name='Pick_Month' class='ckform' size='1' onChange='Pi_Month()'>\n";
for($n=1; $n <=12; $n++) {
   if ($n == $month1) {
      $monthfill.= "<option value='$n' selected>$SMonth[$n]</option>\n";
   } else {
      $monthfill.= "<option value='$n'>$SMonth[$n]</option>\n";   
   }
}
$monthfill.= "</select>";

// Fill Option Year Box 2
$yearfill2 = "<select name='Drop_Year' class='ckform' size='1'>\n";
for($n=$lowyear; $n <=$highyear; $n++) {
   if ($n == $year2) {
      $yearfill2.= "<option value='$n' selected>$n</option>\n";
   } else {
      $yearfill2.= "<option value='$n'>$n</option>\n";   
   }   
}
$yearfill2.= "</select>";

// Fill Option Day Box 2
$dayfill2 = "<select name='Drop_Day' class='ckform' size='1'>\n";
for($n=1; $n <=31; $n++) {
   if ($n == $day2) {
      $dayfill2.= "<option value='$n' selected>$n</option>\n";
   } else {
      $dayfill2.= "<option value='$n'>$n</option>\n";   
   }   
}
$dayfill2.= "</select>";

// Fill Option Month Box 2
$SMonth[1]  = "January";
$SMonth[2]  = "February";
$SMonth[3]  = "March";
$SMonth[4]  = "April";
$SMonth[5]  = "May";
$SMonth[6]  = "June";
$SMonth[7]  = "July";
$SMonth[8]  = "August";
$SMonth[9]  = "September";
$SMonth[10] = "October";
$SMonth[11] = "November";
$SMonth[12] = "December";

$monthfill2 = "<select name='Drop_Month' class='ckform' size='1'>\n";
for($n=1; $n <=12; $n++) {
   if ($n == $month2) {
      $monthfill2.= "<option value='$n' selected>$SMonth[$n]</option>\n";
   } else {
      $monthfill2.= "<option value='$n'>$SMonth[$n]</option>\n";   
   }
}
$monthfill2.= "</select>";
There is some javascript that initially sets the dates based on today's date so I don't want to mess that up either. This is what I am trying to do in text:

if drop-month < pick-month then make the selected item in the year2 box = year2 + 1

Thanks, e