http://expert.csdn.net/Expert/topic/1887/1887844.xml?temp=.5917017

解决方案 »

  1.   

    <script>
    /**
    * getDay 返回星期(星期天=0)
    * @param
    *  y 年
    *  m 月
    *  d 日
    * 假定传入的日期合法
    * 计算范围:1752-9-14以后
    */
    function getDay(y,m,d) {
      y = Number(y);
      m = Number(m);
      d = Number(d);
      if(m==1 || m==2) {
        m += 12;
        y--;
      }
      with(Math)
        var t = d+2*m+floor(3*(m+1)/5)+y+floor(y/4)-floor(y/100)+floor(y/400);
      return (t+1)%7;
    }
    function getDate(y,m) {
      y = Number(y);
      m = Number(m);
      var a = getDay(y,m+1,1);
      var b = getDay(y,m,28);
      if(a<b) a += 7;
      return 27+a-b;
    }
    //alert(getDay(2003,8,9));
    </script><select id=I_Year onChange="seleDate('year')">
    </select>年
    <select id=I_Mon onChange="seleDate('mon')">
    </select>月
    <select id=I_Date onChange="seleDate('date')">
    </select>日<script>
    function genYear(sele,year,length) {
      var d = new Date();
      for(i=0;i<length;i++) {
        sele.options[i] = new Option(i+year,i+year)
        if(i+year == d.getYear())
          n = i;
      }
      sele.options.length = length;
      sele.options[n].selected = true;
    }function genMon(sele,year) {
      var d = new Date();
      for(i=0;i<12;i++) {
        sele.options[i] = new Option(i+1,i+1)
        if(i == d.getMonth())
          n = i;
      }
      sele.options.length = 12;
      sele.options[n].selected = true;
    }function genDate(sele,year,month) {
      var d = new Date(year,month,0);
      var length = getDate(year,month);
      d = new Date();
      for(i=0;i<=length;i++) {
        sele.options[i] = new Option(i+1,i+1)
        if(i+1 == d.getDate())
          n = i;
      }
      sele.options.length = length;
      sele.options[n].selected = true;
    }
    var d = new Date();
    genYear(I_Year,1993,20);
    genMon(I_Mon,d.getYear());
    genDate(I_Date,d.getYear(),d.getMonth()+1);dayChar = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
    function seleDate(mode) {
      switch(mode) {
        case "year":
          genDate(I_Date, I_Year.value, I_Mon.value);
          break;
        case "mon":
          genDate(I_Date, I_Year.value, I_Mon.value);
          break;
        case "date":
          alert(I_Year.value+"-"+I_Mon.value+"-"+I_Date.value+dayChar[getDay(I_Year.value,I_Mon.value,I_Date.value)]);
      }
    }</SCRIPT>
      

  2.   

    <select id=years><option selected>2000</option></select><select id=months onchange="aa()">
    <option >please select:</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    </select>
    <select id=days style="width:100"></select>
    <script>
    function aa()
    {
    var nDay = 0;
    var strYear = ""
    var strmonth = "";
    strYear = years.options[years.selectedIndex].text
    strmonth = months.options[months.selectedIndex].text
    switch(strmonth)
    {
    case '1':
    case '3':
    case '5':
    case '7':
    case '8':
    case '10':
    case '12':
    nDay = 31
    break;
    case '4':
    case '6':
    case '9':
    case '11':
    nDay = 30;
    break;
    case '2':
    var nYear = parseInt(strYear);
    if(((nYear % 400) == 0) || ((nYear % 4 == 0) && nYear % 100 != 0)) nDay = 29; else nDay = 28;
    break;
    }
    for(var i =1;i<= nDay;i++)
    { var oE = document.createElement("option")

    oE.text = i ;
    days.appendChild(oE);

    }
    }
    </script>
      

  3.   

    复杂,判断每个月的天数就可以了,不用判断闰年我的
    http://www.sayee.com/cloudchen/js/date.htm