Randy Posted March 3, 2006 Share Posted March 3, 2006 ok, i would like to make a set of drop-down boxes where people can select the datebut say, if you selected March, the second dropdown box would automatically have 31 daysor if you selected April, there would only be 30is this possible with php / how would i do it...thanks in advance :) Link to comment https://forums.phpfreaks.com/topic/4018-dynamic-date-dropdown-box/ Share on other sites More sharing options...
Barand Posted March 3, 2006 Share Posted March 3, 2006 Better to do something like this with javascript[code]<script> function daymenu(form, m) { da = new Array(31,28,31,30); n = form.day.options.length; //clear array for (var i=1; i <= n; i++) { form.day.options[i] = null; } //add new values for new month for (i=1; i <= da[m-1]; i++) { form.day.options[i] = new Option(i, i, false); } }</SCRIPT><FORM> <SELECT name='month' onChange='daymenu(this.form, this.value);'> <OPTION value=''>- Month -</OPTION> <OPTION value='1'>Jan</OPTION> <OPTION value='2'>Feb</OPTION> <OPTION value='3'>Mar</OPTION> <OPTION value='4'>Apr</OPTION> </SELECT> <SELECT name='day'> <OPTION>-day-</OPTION> </SELECT></FORM>[/code] Link to comment https://forums.phpfreaks.com/topic/4018-dynamic-date-dropdown-box/#findComment-13986 Share on other sites More sharing options...
Randy Posted March 4, 2006 Author Share Posted March 4, 2006 how would i do some sort of leap year detector, then it changes the february daysin thought something likeif(round((Year+1900)/4) != ((Year+1900)/4)){ Link to comment https://forums.phpfreaks.com/topic/4018-dynamic-date-dropdown-box/#findComment-14134 Share on other sites More sharing options...
Barand Posted March 4, 2006 Share Posted March 4, 2006 Try[code]$febDays = date('t', mktime(0,0,0,2,1,date('Y')));[/code] Link to comment https://forums.phpfreaks.com/topic/4018-dynamic-date-dropdown-box/#findComment-14153 Share on other sites More sharing options...
Randy Posted March 4, 2006 Author Share Posted March 4, 2006 thanks!*EDIT*ah... i also have a year select so that means that the days in february will have to be dependant on that too :( Link to comment https://forums.phpfreaks.com/topic/4018-dynamic-date-dropdown-box/#findComment-14195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.