年月日三级导航菜单
<html>
<head>
<script type="text/javascript">
function createSelect(ActionFlag)
{
var selYear = document.getElementById("tYEAR");
var selMonth = document.getElementById("tMON");
var selDay = document.getElementById("tDAY");
var dt = new Date();
//
if(ActionFlag == 1)
{
MinYear = dt.getFullYear();
MaxYear = dt.getFullYear()+5;
for(var i = MinYear; i <= MaxYear; i++)
{
var op = document.createElement("OPTION");
op.value = i;
op.innerHTML = i;
selYear.appendChild(op);
}
selYear.selectedIndex = 0;
for(var i = 1; i < 13; i++)
{
var op = document.createElement("OPTION");
op.value = i;
op.innerHTML = i;
selMonth.appendChild(op);
}
selMonth.selectedIndex = dt.getMonth();
}
//
var date = new Date(selYear.value, selMonth.value, 0);
var daysInMonth = date.getDate();
selDay.options.length = 0;
for(var i = 1; i <= daysInMonth ; i++)
{
var op = document.createElement("OPTION");
op.value = i;
op.innerHTML = i;
selDay.appendChild(op);
}
//alert();
selDay.selectedIndex = dt.getDate() - 1;
}
</script>
</head>
<body>
<select id="tYEAR" size="1" onChange="javaScript:createSelect()"></select>
<select id="tMON" size="1" onChange="javaScript:createSelect();"></select>
<select id="tDAY" size="1" ></select>
<script type="text/javascript">createSelect(1);</script>
</body>
</html> <script language="javascript">
<!--
var i=0 ;
function addInput() {
var o = document.createElement("option");
o.value = "s" + i++ ;
o.attachEvent("onclick",addInput);
document.body.appendChild(o);
o = null;
}
//-->
</script>