Posted By

tylerhall on 11/30/-1


Tagged

month day year data dropdown


Versions (?)

Who likes this?

11 people have marked this snippet as a favorite

luxuryluke
trickychicken
Davin
ckester
waako
chrisjlee
The14thGOD
ba11in
seanpowell
wdeer
dekehooper


Month Day Year Dropdown


 / Published in: HTML
 

  1. <select name="month" id="month">
  2. <option value="1" <?PHP if($month==1) echo "selected";?>>January</option>
  3. <option value="2" <?PHP if($month==2) echo "selected";?>>February</option>
  4. <option value="3" <?PHP if($month==3) echo "selected";?>>March</option>
  5. <option value="4" <?PHP if($month==4) echo "selected";?>>April</option>
  6. <option value="5" <?PHP if($month==5) echo "selected";?>>May</option>
  7. <option value="6" <?PHP if($month==6) echo "selected";?>>June</option>
  8. <option value="7" <?PHP if($month==7) echo "selected";?>>July</option>
  9. <option value="8" <?PHP if($month==8) echo "selected";?>>August</option>
  10. <option value="9" <?PHP if($month==9) echo "selected";?>>September</option>
  11. <option value="10" <?PHP if($month==10) echo "selected";?>>October</option>
  12. <option value="11" <?PHP if($month==11) echo "selected";?>>November</option>
  13. <option value="12" <?PHP if($month==12) echo "selected";?>>December</option>
  14.  
  15. <select name="day" id="day">
  16. <option value="1" <?PHP if($day==1) echo "selected";?>>1</option>
  17. <option value="2" <?PHP if($day==2) echo "selected";?>>2</option>
  18. <option value="3" <?PHP if($day==3) echo "selected";?>>3</option>
  19. <option value="4" <?PHP if($day==4) echo "selected";?>>4</option>
  20. <option value="5" <?PHP if($day==5) echo "selected";?>>5</option>
  21. <option value="6" <?PHP if($day==6) echo "selected";?>>6</option>
  22. <option value="7" <?PHP if($day==7) echo "selected";?>>7</option>
  23. <option value="8" <?PHP if($day==8) echo "selected";?>>8</option>
  24. <option value="9" <?PHP if($day==9) echo "selected";?>>9</option>
  25. <option value="10" <?PHP if($day==10) echo "selected";?>>10</option>
  26. <option value="11" <?PHP if($day==11) echo "selected";?>>11</option>
  27. <option value="12" <?PHP if($day==12) echo "selected";?>>12</option>
  28. <option value="13" <?PHP if($day==13) echo "selected";?>>13</option>
  29. <option value="14" <?PHP if($day==14) echo "selected";?>>14</option>
  30. <option value="15" <?PHP if($day==15) echo "selected";?>>15</option>
  31. <option value="16" <?PHP if($day==16) echo "selected";?>>16</option>
  32. <option value="17" <?PHP if($day==17) echo "selected";?>>17</option>
  33. <option value="18" <?PHP if($day==18) echo "selected";?>>18</option>
  34. <option value="19" <?PHP if($day==19) echo "selected";?>>19</option>
  35. <option value="20" <?PHP if($day==20) echo "selected";?>>20</option>
  36. <option value="21" <?PHP if($day==21) echo "selected";?>>21</option>
  37. <option value="22" <?PHP if($day==22) echo "selected";?>>22</option>
  38. <option value="23" <?PHP if($day==23) echo "selected";?>>23</option>
  39. <option value="24" <?PHP if($day==24) echo "selected";?>>24</option>
  40. <option value="25" <?PHP if($day==25) echo "selected";?>>25</option>
  41. <option value="26" <?PHP if($day==26) echo "selected";?>>26</option>
  42. <option value="27" <?PHP if($day==27) echo "selected";?>>27</option>
  43. <option value="28" <?PHP if($day==28) echo "selected";?>>28</option>
  44. <option value="29" <?PHP if($day==29) echo "selected";?>>29</option>
  45. <option value="30" <?PHP if($day==30) echo "selected";?>>30</option>
  46. <option value="31" <?PHP if($day==31) echo "selected";?>>31</option>
  47.  
  48. <select name="year" id="year">
  49. <?PHP for($i=date("Y"); $i<=date("Y")+2; $i++)
  50. if($year == $i)
  51. echo "<option value='$i' selected>$i</option>";
  52. else
  53. echo "<option value='$i'>$i</option>";
  54. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bidfreelancers on April 25, 2007

HI,

For months i think this looks better

Posted By: bidfreelancers on April 25, 2007

HI,

For months i think this looks better

Posted By: bidfreelancers on April 25, 2007

dont know whats wrong i pasted the code but i cant see anything now is this bug in this forum? or i made a mistake

Posted By: phill_nerv on November 3, 2009

with the year function you are calling the date function every loop a better way would be something like:

Posted By: phill_nerv on November 3, 2009

with the year function you are calling the date function every loop a better way would be something like:

<code>
Posted By: phill_nerv on November 3, 2009

lol this comment system is useless!

Basically a better way for the year function would be to assign a var with the date(y) function result in and then assign another var for when you want the loop to end at (e.g $yearend = $yearstart-100) .

Loop as normal just replacing the date function calls with your variables.

You need to login to post a comment.