急死 我了 帮帮忙!!!JS日期 显示错误
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<script language= "javascript ">
function proStartDate()
{
document.theform.startYear.options.length=5;
//循环请选择
document.theform.startYear.options[0].text= "请选择 ";
document.theform.startYear.options[0].value=0;
for (i=1;i <=5;i++)
{
document.theform.startYear.options[i].text=2006+i;
document.theform.startYear.options[i].value=2006+i;
}
//循环请选择
document.theform.startMonth.options.length=13;
document.theform.startMonth.options[0].text= "请选择 ";
document.theform.startMonth.options[0].value=0;
for (i=1;i <=12;i++)
{
document.theform.startMonth.options[i].text=i+0;
document.theform.startMonth.options[i].value=i+0;
}
//请选择判断
var month=document.theform.startMonth.value;
var year =document.theform.startYear.value;
if ( "2 ".indexOf(month) != -1)
{
if (year%4==0 && year%100 !=0 ||year%400 ==0 )
{
document.theform.startDay.options.length=30;
document.theform.startDay.options[0].text= "请选择 ";
document.theform.startDay.options[0].value=0;
for (i=1;i <=29;i++)
{
document.theform.startDay.options[i].text=i+0;
document.theform.startDay.options[i].value=i+0;
}
}
else
{
document.theform.startDay.options.length=29;
document.theform.startDay.options[0].text= "请选择 ";
document.theform.startDay.options[0].value=0;
for (i=1;i <=28;i++)
{
document. theform.startDay.options[i].text=i+0;
document.theform.startDay.options[i].value=i+0;
}
}
}
else if ( "135781012 ".indexOf(month) != -1)
{
document.theform.startDay.options.length=32;
document.theform.startDay.options[0].text= "请选择 ";
document.theform.startDay.options[0].value=0;
for (i=1;i <=31;i++)
{
document. theform.startDay.options[i].text=i+0;
document.theform.startDay.options[i].value=i+0;
}
}
else
{
document.theform.startDay.options.length=31;
document.theform.startDay.options[0].text= "请选择 ";
document.theform.startDay.options[0].value=0;
for (i=1;i <=30;i++)
{
document. theform.startDay.options[i].text=i+0;
document.theform.startDay.options[i].value=i+0;
}
}
}
</script>
<body onload= "proStartDate(); ">
<form id= "theform " name= "theform " method= "post " action= " ">
<select name= "startYear " id= "startYear ">
</select>
年
<select name= "startMonth " id= "startMonth " onchange= " proStartDate(); ">
</select>
</label>
月
<select name= "startDay " id= "startDay " onchange= " proStartDate(); ">
</select>
日
</form>
</body>
</html>
[解决办法]
document.theform.startYear.options.length=6;
请选择也算一个