HTML:
<select name='day' id='day'> <option selected='selected' disabled='disabled'>День</option> <?php for($day = 1; $day <= 31; $day++){ echo "<option value=\"". $day ."\">$day</option>\n"; } ?> </select> <select name='month' id='month'> <option selected='selected' disabled='disabled'>Месяц</option> <?php for($month = 1; $month <= 12; $month++){ switch($month){ case 1: $month_name = "января"; break; case 2: $month_name = "февраля"; break; case 3: $month_name = "марта"; break; case 4: $month_name = "апреля"; break; case 5: $month_name = "мая"; break; case 6: $month_name = "июня"; break; case 7: $month_name = "июля"; break; case 8: $month_name = "августа"; break; case 9: $month_name = "сентября"; break; case 10: $month_name = "октября"; break; case 11: $month_name = "ноября"; break; case 12: $month_name = "декабря"; } echo "<option value=\"". $month."\"> $month_name</option>\n"; }?> </select> <select name='year' id='year'> <option selected='selected' disabled='disabled'>Год</option> <?php for($year = date("Y") - 80; $year <= date("Y"); $year++){ echo "<option value=\"". $year ."\">$year</option>\n";}?> </select> Js:
$("#year").change = $("#month").change(function(){ var year = document.getElementById('year').value, month = document.getElementById('month').value, md = (new Date(year, month, 0, 0, 0, 0, 0)).getDate(); var select = document.getElementById('day'); select.options.length = 0; for (var i = 1; i <= md; i++){ var option = document.createElement('OPTION'); option.innerHTML = option.value = i; select.appendChild(option); } }); Actually, how to make, that there was a leap year accounting when choosing a month and a year?