tmpString=<script language="javascript">
function YearID_TC(obj)
{
//取出下拉框的值
var vYear=obj.value-10;
//清除下拉框
obj.length=0;

for(i=0;i<21;i)
{
var opt=document.createElement("OPTION");
obj.add(opt);
opt.value=vYear+i;
opt.text=vYear+i+"年";
}
obj.value=vYear+10;
}
function ctlID_SetValue(obj1,obj2)
{
document.all("ctlID").value=obj1.value+"-"+obj2.value;
}
</script>;

解决方案 »

  1.   

    年月日选择,以资参考
    http://jkisjk.vip.sina.com/html/YearMonthDaySelect.htm
      

  2.   

    <script language="javascript">
    function RepeatYear(DateYear)
    {
    var strReYear ;
    var blnYearFlag = false;
    switch (DateYear.length)
    {
    case 0 :
    blnYearFlag = true;
    break;
    case 1 :
    DateYear = "200" + DateYear;
    break;
    case 2 :
    DateYear = "20" + DateYear;
    break;
    case 3 :
    DateYear = "2" + DateYear;
    break;
    }
    if(blnYearFlag)
    {
    strReYear = "";
    }
    else
    {
    strReYear = DateYear;
    }
    return strReYear;
    }function RepeatYearMonthDay(strYear,strMonth,strDay,intFromOrTo)
    {
    var strYearMonthDay = new Array(3);
    if(intFromOrTo == 1)
    {
    if(strMonth == "")

    strMonth = "01";
    }
    if(strDay == "")
    {
    strDay = "01";
    }
    }
    else
    {
    if(strMonth == "")

    strMonth = "12";
    if(strDay == "")
    {
    strDay = "31";
    }
    }
    else
    {
    if(strDay == "")
    {
    strDay = "31";
    }
    }
    }
    strYearMonthDay[0] = strYear;
    strYearMonthDay[1] = strMonth;
    strYearMonthDay[2] = strDay;
    return strYearMonthDay;
    }
    function CreateDayCombox(strYearName,strMonthName,strComboxDayName)
    {
    var txtBoxYear;
    var txtBoxMonth;
    var txtBoxday;
    var strNumber="1234567890";
    var strPartYear;
    var intIndex;
    var strMonth;
    var strYear;
    var strDay;
    var strval;
    var i;
    txtBoxYear  = document.getElementsByName(strYearName);
    txtBoxMonth  = document.getElementsByName(strMonthName);
    txtBoxDay  = document.getElementsByName(strComboxDayName);
    strYear  = RepeatYear(txtBoxYear[0].value)
    strMonth   = txtBoxMonth[0].value;

    txtBoxDay[0].length  = 1;
    txtBoxDay[0].options[0].value  = "";
    txtBoxDay[0].options[0].text  = "";

    if(strYear !="" && strMonth!="")
    {
    for(i=0;i<strYear.length;i++)
    {
    strPartYear=strYear.substring(i,i+1);
    if(strNumber.indexOf(strPartYear,0)==-1)
    {
    return false;
    }
    }

    if((parseInt(strYear)%4==0&&parseInt(strYear)%100!=0)||(parseInt(strYear)%400==0)) 
    {
    strYear = true;
    }
    else
    {
    strYear = false;
    }
    switch(strMonth)
    {
    case "02":
    strDay = 28;
    if(strYear == true)
    {
    strDay = 29;
    }
    break;
    case "04":
    case "06":
    case "09":
    case "11":
    strDay = 30;
    break;
    default:
    strDay = 31;
    break;
    }
    if(strDay!="")
    {
    txtBoxDay[0].length  = strDay+1;
    txtBoxDay[0].options[0].value  = "";
    txtBoxDay[0].options[0].text  = "";
    for(i = 1;i < strDay+1;i++)
    {
    if(i<10)
    {
    strval = "0"+i;
    }
    else
    {
    strval = i;
    }
    txtBoxDay[0].options[i].value  = strval;
    txtBoxDay[0].options[i].text  = strval;
    }
    }
    }
    }
    </script>
    <html>
    <head>
    </head>
    <body>
    <%Call ComboxCreateTime("comboxFromYear","comboxFromMonth","comboxFromDay")%>
    </body>
    </html>
    <%
    Sub ComboxCreateTime(comboxYearName,comboxMonthName,comboxDayName)
    response.Write("<input name="&comboxYearName&" type=text size=4 maxlength='4' onChange='CreateDayCombox("&""""&comboxYearName&""""&","&""""&comboxMonthName&""""&","&""""&comboxDayName&""""&")'> 年 ")
    response.Write("<select name="&comboxMonthName&" onChange='CreateDayCombox("&""""&comboxYearName&""""&","&""""&comboxMonthName&""""&","&""""&comboxDayName&""""&")'>")
    response.Write("<option selected value='' ></option>")
    For i = 1 To 12
    If len(i) = 1 Then
    i = "0" & i
    End If
    response.Write("<option value="&i&">"&i&"</option>")
    Next
    response.Write("</select> 月 ")
    response.Write("<select name="&comboxDayName&" style='width:1cm'>")
    response.Write("<option selected></option>")
    response.Write("</select> 日")
    End Sub
    %>
      

  3.   

    楼主试下上面的代码,年你把它改称select就行了
      

  4.   

    <html>
    <head>
    <title>年月日三下拉框联动</title>
    <meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
    <meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'>
    </head><body>
    <form name=form1>
      <select name=YYYY onchange="YYYYDD(this.value)">
        <option value="">请选择 年</option>
      </select>
      <select name=MM   onchange="MMDD(this.value)">
        <option value="">选择 月</option>
      </select>
      <select name=DD>
        <option value="">选择 日</option>
      </select>
    </form><script language="JavaScript"><!--
    function YYYYMMDDstart()
    {
        MonHead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];    //先给年下拉框赋内容
        var y   = new Date().getFullYear();
        for (var i = (y-30); i < (y+30); i++) //以今年为准,前30年,后30年
            document.form1.YYYY.options.add(new Option(" "+ i +" 年", i));    //赋月份的下拉框
        for (var i = 1; i < 13; i++)
            document.form1.MM.options.add(new Option(" " + i + " 月", i));    document.form1.YYYY.value = y;
        document.form1.MM.value = new Date().getMonth() + 1;
        var n = MonHead[new Date().getMonth()];
        if (new Date().getMonth() ==1 && IsPinYear(YYYYvalue)) n++;
            writeDay(n); //赋日期下拉框Author:meizz
        document.form1.DD.value = new Date().getDate();
    }
    if(document.attachEvent)
      window.attachEvent("onload", YYYYMMDDstart);
    else
      window.addEventListener('load', YYYYMMDDstart, false);
    function YYYYDD(str) //年发生变化时日期发生变化(主要是判断闰平年)
    {
        var MMvalue = document.form1.MM.options[document.form1.MM.selectedIndex].value;
        if (MMvalue == ""){ var e = document.form1.DD; optionsClear(e); return;}
        var n = MonHead[MMvalue - 1];
        if (MMvalue ==2 && IsPinYear(str)) n++;
            writeDay(n)
    }
    function MMDD(str)  //月发生变化时日期联动
    {
        var YYYYvalue = document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value;
        if (YYYYvalue == ""){ var e = document.form1.DD; optionsClear(e); return;}
        var n = MonHead[str - 1];
        if (str ==2 && IsPinYear(YYYYvalue)) n++;
            writeDay(n)
    }
    function writeDay(n)  //据条件写日期的下拉框
    {
        var e = document.form1.DD; optionsClear(e);
        for (var i=1; i<(n+1); i++)
            e.options.add(new Option(" "+ i + " 日", i));
    }
    function IsPinYear(year)//判断是否闰平年
    {   return(0 == year%4 && (year%100 !=0 || year%400 == 0));}
    function optionsClear(e)
    {
        e.options.length = 1;
    }
    //--></script>
    </body>
    </html>
      

  5.   

    对meizz代码的一点小意见:
    1.选了2003-02-05后,将年份改一下,就又要重选日期了
    2.得到某月天数的代码,可以用“new Date(2001,2,0).getDate()”来得到,不必用“月份的天数数组+平闰年判断”