<head>
<title>javascripttest</title>
<script type="text/javascript">
function setDay()
{
var themonth=document.getElementById("month");
var themaxmonthday=31;
if(themonth.value=="2")
{
themaxmonthday=28;
}
var theday=document.getElementById("day");
var tempdaylength=theday.options.length;
for(var j=tempdaylength;j>0;j--)
{
theday.options.remove(j);
}
for(var i=1;i<=themaxmonthday;i++)
{
var theOption=document.createElement("option");
theOption.innerHTML=i+"日";
theOption.value=i;
theday.appendChild(theOption);
}
}
</script>
</head>
<body>
<select id="month" onchange="setDay()">
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
<option value="4">4月</option>
<option value="5">5月</option>
<option value="6">6月</option>
<option value="12">12月</option>
</select>
<select id="day">
</select>
</body>
</html>