Hello

I want to create an Date of birth dropdown item with javascript. I already create Month and year successfully.

for month this code is used
Code:
<script>
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
                document.write('<select name="birthday">');
                	document.write('<option>Month</option>');
					for(i=0;i<months.length;i++){
						document.write('<option value=' + months[i] +'>' + months[i] + '</option>');
						}
				document.write('</select>');
				</script>
and for year this code is used:

Code:
<script>
			document.write('<select name="year">Year');
            
			var i = 1994;
			var y = "Year";
			document.write('<option value=' + y + '>' + y + '</option>');// To show Year by Default
            while (i < 2050) {
				document.write('<option value=' + i + '>' + i + '</option>');
				i++;
			}
            document.write('</select>');
			</script>
Now i'm satisfied with Month and date. But I having a problem with The Date However, i can use the above code (year) for date (1 to 31) but Some months are not 31. How can i fix it . Please help me

Best regards
ehsan