I am in the process of developing a virtual JavaScript calendar dropdown feature. I aim to have the correct number of days displayed upon selecting a month, but currently, no days appear when I make a selection. Can someone please assist me with this issue? I must avoid using jQuery again as I risk losing my job this time.
<html>
<head>
<script type="text/javascript">
function show(x) {
var mon = document.getElementById(x).innerHTML;
//if month value is nothing display no days
if (mon == "") {
for(i=1; i < 32; i++) {
document.getElementById("day" + i).style.display="none";
}
} else if ((mon == "January") || (mon == "March") || (mon == "May") || (mon == "July") || (mon == "August") || (mon == "October") || (mon == "December")) {
for(i=1; i < 32; i++) {
document.getElementById("day" + i).style.display="";
}
} else if ((mon == "April") || (mon == "June") || (mon == "September") || (mon == "November")) {
for(i=1; i < 31; i++) {
document.getElementById("day" + i).style.display="";
}
} else {
for(i=1; i < 30; i++) {
document.getElementById("day" + i).style.display="";
}
}
}
</script>
</head>
<body>
Calendar<br>
<hr align="left" width="200px"/>
--Year ------ Month ----- Day<br>
<select name="year">
<option value="defaulty"></option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
<select name="month" onchange="show(this.value)">
<option id="defaultm" value="defaultm"></option>
<option id="January" value="January">January</option>
<option id="February" value="February">February</option>
<option id="March" value="March">March</option>
<option id="April" value="April">April</option>
<option id="May" value="May">May</option>
<option id="June" value="June">June</option>
<option id="July" value="July">July</option>
<option id="August" value="August">August</option>
<option id="September" value="September">September</option>
<option id="October" value="October">October</option>
<option id="November" value="November">November</option>
<option id="December" value="December">December</option>
</select>
<select name="day">
<option id="defaultd" value="defaultd"></option>
for(i=1; i < 32; i++) {
<option id="day" + i value="day" + i style="display:none">i</option>
}
</select>
</body>
</html>