<script language="javascript">
var months = [1,3,5,7,8,10,12];
function inArray(arr,str)
{
var re = false;
for(i=0;i<arr.length;i++)
if(str == arr[i])
{
re = true;
break;
}
return re;
}
function $(id)
{
return document.getElementById(id);
}
function init(y,m,d)
{
var dt = new Date();//
for(i=2000;i<dt.getFullYear()+5;i++)
$(y).options[i-1999] = new Option(i,i);
for(i=1;i<13;i++)
$(m).options[i] = new Option(i,i);
$(y).onchange = function (){check(y,m,d);};
$(m).onchange = function (){check(y,m,d);};
}
function check(y,m,d)
{
y = $(y).value;
m = $(m).value;
$(d).options.length = 1;
if(inArray(months,m))
for(i=1;i<32;i++)
$(d).options[i] = new Option(i,i);
else if(m==2&&y%4==0&&y%100!=0)
for(i=1;i<30;i++)
$(d).options[i] = new Option(i,i);
else if(m==2&&(y%4!=0||y%100==0))
for(i=1;i<29;i++)
$(d).options[i] = new Option(i,i);
else
for(i=1;i<31;i++)
$(d).options[i] = new Option(i,i);
}
window.onload = function (){init('y','m','d');};
</script>
<select name="y" id="y">
<option value="">请选择</option>
</select>
<select name="m" id="m"><option value="">请选择</option></select>
<select name="d" id="d"><option value="">请选择</option></select>