Makes a html year select starting at the current + the next 2 years


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*
  2. Makes a html year select starting at the current + the next 2 years
  3. The string passed is the name of the select.
  4. usage:
  5. echo select_years('pickup_year');
  6. */
  7. function select_years($name){
  8. return '
  9. <select name="'.$name.'">
  10. <option value="'.date("Y").'" SELECTED>'.date("Y").'</option>
  11. <option value="'.(date("Y")+1).'">'.(date("Y")+1).'</option>
  12. <option value="'.(date("Y")+2).'">'.(date("Y")+2).'</option>
  13. </select>';
  14. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.