<div style="600px; height:100px;">
<select id="year">
</select> 年
<select id="month" onchange="FillDay()">
</select> 月
<select id="day">
</select> 日
</div>
<script type="text/javascript">
FillYear();
FillMonth();
FillDay();
function FillYear()
{
var sj = new Date();
var nian = sj.getFullYear();
var s = "";
for(var i=nian-5;i<nian+6;i++)
{
if(i==nian)
{
s +="<option selected='selected'>"+i+"</option>";
}
else
{
s +="<option>"+i+"</option>";
}
}
document.getElementById("year").innerHTML = s;
}
function FillMonth()
{
var sj = new Date();
var yue = sj.getMonth()+1;
var s = "";
for(var i=1;i<13;i++)
{
if(i==yue)
{
s +="<option selected='selected'>"+i+"</option>";
}
else
{
s +="<option>"+i+"</option>";
}
}
document.getElementById("month").innerHTML=s;
}
function FillDay()
{
var sj = new Date();
var tian = sj.getDate();
//取月份求天数
var yue = document.getElementById("month").value;
var n = 31;
if(yue==4 || yue==6 ||yue==9 ||yue==11)
{
n = 30;
}
else if(yue==2)
{
n=28;
}
//用循环添加
var s = "";
for(var i=1;i<n+1;i++)
{
if(i==tian)
{
s +="<option selected='selected'>"+i+"</option>";
}
else
{
s +="<option>"+i+"</option>";
}
}
document.getElementById("day").innerHTML = s;
}