I have 3 dropdown selections for the user to input her birthday:
<select id= "birthYear"></select>
<select id="birthMonth"></select>
<select id= "birthDate"></select>
I want to populate the last selection (birthDate) with the right number of date options (28, 29, 30, 31) based on the selected year and month (in order to account for difference of days per month and per leap years).
Ive tried various versions of the following, but I NEED HELP AND INSIGHT, PLZ!:
function daysInMonth(m, y) {
this.m = birthMonth.selectedIndex;
this.y = birthYear.value;
return new Date().getDate(y, m, 0);
}
function popDate() {
for (i = 1; 1 < daysInMonth + 1; i++) {
var opt = document.createElement('option');
opt.value = i;
opt.innerHTML = i;
birthDate.appendChild(opt);
}
}
popDate();