Jump to content

change drop down list from current to past years to current to future years


Lisa23

Recommended Posts

Hi i have this drop down list current the year is 2010 and downwards but i want to change the list to 2010 upwards u can notice on the 50-- so shows current year minus so current is 2010 to 61 how can i change 2010 to 2030 or sunfin??

 

echo '<select name="year_of_birth">',"\n";
    $year = date("Y");
    for ($i = $year;$i > $year-50;$i--) {
      if($i == $thisYear) { 
        $s = ' selected'; 
      } else { 
        $s='';
      }
      echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n";
    }
  echo '</select>',"\n";

$year = range(2010, 2061); // creates array with all values from 2010 through 2061
echo '<select name="year_of_birth">',"\n";
foreach( $year as $v ) {
     echo "<option value=\"$v\"";
          if( $v == $thisYear ) {
               echo ' selected="selected"';
          }
     echo ">$v</option>";
}

Thank you very much i managed to fix by changing this line moe than to less - made plus and minus minus made plus plus but thnak u very much

for ($i = $year;$i > $year-50;$i--)  to for ($i = $year;$i < $year-50;$i--)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.