javascript 日期下拉列表

javascript日期下拉列表

<scripttype="text/javascript">

functioncreateSelect(ActionFlag)

{

varselYear=document.getElementById("tYEAR");

varselMonth=document.getElementById("tMON");

varselDay=document.getElementById("tDAY");

vardt=newDate();

if(ActionFlag==1)

{

MaxYear=dt.getFullYear();

MinYear=dt.getFullYear()-100;

for(vari=MinYear;i<=MaxYear;i++)

{

varop=document.createElement("OPTION");

op.value=i;

op.innerHTML=i;

selYear.appendChild(op);

}

selYear.selectedIndex=0;

for(vari=1;i<13;i++)

{

varop=document.createElement("OPTION");

op.value=i;

op.innerHTML=i;

selMonth.appendChild(op);

}

selMonth.selectedIndex=dt.getMonth();

}

vardate=newDate(selYear.value,selMonth.value,0);

vardaysInMonth=date.getDate();

selDay.options.length=0;

for(vari=1;i<=daysInMonth;i++)

{

varop=document.createElement("OPTION");

op.value=i;

op.innerHTML=i;

selDay.appendChild(op);

}

//alert();

selDay.selectedIndex=dt.getDate()-1;

}

</script>

<selectid="tYEAR"name="tYEAR"size="1"onChange="createSelect()"></select>年

<selectid="tMON"name="tMON"size="1"onChange="createSelect();"></select>月

<selectid="tDAY"name="tDAY"size="1"></select>日*

<scripttype="text/javascript">createSelect(1);</script>

相关推荐