Each time the user selects a year or month, JavaScript gets the correct number of days in that month and updates the pull down menu. The script is Y2K compliant and also works for leap years .
Add the below code to the <body> section of your page:
<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin function
populate(objForm,selectIndex){ timeA =newDate(objForm.year.options[objForm.year.selectedIndex].text,
objForm.month.options[objForm.month.selectedIndex].value,1); timeDifference =
timeA -86400000; timeB =newDate(timeDifference); var
daysInMonth =
timeB.getDate(); for(var
i =0;
i <
objForm.day.length;
i++){ objForm.day.options[0]=null;
} for(var
i =0;
i <
daysInMonth;
i++){ objForm.day.options[i]=newOption(i+1);
} document.f1.day.options[0].selected=true;
} function
getYears(){
// You can easily customize what
years can be used var
years =newArray(1997,1998,1999,2000,2001,2005)
for(var
i =0;
i <document.f1.year.length;
i++){ document.f1.year.options[0]=null;
} timeC =newDate(); currYear =
timeC.getFullYear(); for(var
i =0;
i <
years.length;
i++){ document.f1.year.options[i]=newOption(years[i]);
} document.f1.year.options[2].selected=true;
} window.onLoad
=
getYears; // End --> </script> <center> <formname=f1> <tableborder=0>
<tr>
<td
align=center> <selectname=yearonChange="populate(this.form,this.form.month.selectedIndex);">
<optionselectedvalue=99>1999</option>
<optionvalue=00>2000</option>
<optionvalue=01>2001</option>
<optionvalue=02>2002</option>
<optionvalue=00>2003</option>
<optionvalue=01>2004</option>
<optionvalue=02>2005</option>
<optionvalue=00>2006</option>
<optionvalue=01>2007</option>
<optionvalue=02>2008</option>
</select>