日期:2014-05-17 浏览次数:20660 次
<script type="text/javascript">
function getdate()
{
var i=document.getElementById('year').value;
var j=document.getElementById('month').value;
var k=document.getElementById('day').value;
return i+"年"+j+"月"+k+"日";
}
function checkdate(){
var select = document.getElementById('day');
var year = document.getElementById('year').value;
switch(document.getElementById('month').value){
case '1':
case '3':
case '5':
case '7':
case '8':
case '10':
case '12':
select.length=31;
select.options[28].text=29;
select.options[29].text=30;
select.options[30].text=31;
break;
case '4':
case '6':
case '9':
case '11':
select.length=30;
select.options[28].text=29;
select.options[29].text=30;
break;
case '2':
if((year%4==0 && year%100!=0)
------解决方案--------------------
year%400==0){
select.length=29;
select.options[28].text=29;
}else{
select.length=28;
}
break;
default:alert("非法的月份"+document.getElementById('month').value);
}
}
</script>
<html>
<body>
<select name=""id="year" style="width:60px; margin-right:5px" onclick="checkdate();">
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>