select id="Year" name="Year"option value=""/option/select年
select id="Month" name="Month"/select月
select id="Day" name="Day"/select日br /
select id="iYear" name="iYear"option value=""/option/select年
select id="iMonth" name="iMonth"/select月select id="iDay" name="iDay"/select日
script language="javascript"
!--
//使用方法(对象区别字符串,默认选中日期,时间段),无顺序要求
PPDayselect("");
PPDayselect("i","1988-8-8","1988-1999");
function PPDayselect(){var str=["","1940-2009","0-0-0"];for(var i=0;iarguments.length;i++){if(arguments[i].split("-").length==1){str[0]=arguments[i]};if(arguments[i].split("-").length==2){str[1]=arguments[i]};if(arguments[i].split("-").length==3){str[2]=arguments[i]};}str[1]=str[1].split("-");if(str[2]=="0-0-0"){str[2]=str[1][0]+"-01-01";}str[2]=str[2].split("-");str[1][0]=parseInt(str[1][0]);str[1][1]=parseInt(str[1][1]);if(str[2][1].length2){str[2][1]="0"+str[2][1];}if(str[2][2].length2){str[2][2]="0"+str[2][2];}PPDayselect1(str[0]+"Year",str[1][0],str[1][1]-str[1][0]+1);PPDayselect1(str[0]+"Month",1,12);document.getElementById(str[0]+"Year").onchange=function(){PPDayselect2(str[0]);};document.getElementById(str[0]+"Month").onchange=function(){PPDayselect2(str[0]);};document.getElementById(str[0]+"Year").value=str[2][0];document.getElementById(str[0]+"Month").value=str[2][1];PPDayselect2(str[0]);document.getElementById(str[0]+"Day").value=str[2][2];
}
function PPDayselect1(ObjectName,StartNum,Length){var o=document.getElementById(ObjectName);o.options.length=Length;var ii;for(var i=0;iLength;i++){ii=i+StartNum;if(ii10){ii="0"+ii;}o.options[i]=new Option(ii,ii);}}
function PPDayselect2(str){var DayLength=[31,28,31,30,31,30,31,31,30,31,30,31];var Year=document.getElementById(str+"Year").value;var Month=document.getElementById(str+"Month");if(Year%4==0){DayLength[1]=29;}else{DayLength[1]=28;}PPDayselect1(str+"Day",1,DayLength[Month.selectedIndex]);}
//--
/script