• 日期时间选择


    <div style="600px; height:100px;">

          

        <select id="year">

        </select>

        年

        <select id="month" onchange="FillDay()">

        </select>

        月

           <select id="day">

        </select>

        日

       

    </div>

    </body>

    <script type="text/javascript">

    FillYear();

    FillMonth();

    FillDay();

    function FillYear()

    {

           var sj = new Date();

           var nian = sj.getFullYear();

          

           var s = "";

           for(var i=nian-5;i<nian+6;i++)

           {

                  if(i==nian)

                  {

                         s +="<option selected='selected'>"+i+"</option>";

                  }

                  else

                  {

                         s +="<option>"+i+"</option>";

                  }

           }

          

           document.getElementById("year").innerHTML = s;

    }

    function FillMonth()

    {

           var sj = new Date();

        var yue = sj.getMonth()+1;

          

           var s = "";

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

           {

                  if(i==yue)

                  {

                         s +="<option selected='selected'>"+i+"</option>";

                  }

                  else

                  {

                         s +="<option>"+i+"</option>";

                  }

           }

          

           document.getElementById("month").innerHTML=s;

    }

    function FillDay()

    {

           var sj = new Date();

        var tian = sj.getDate();

          

           //取月份求天数

           var yue = document.getElementById("month").value;

           var n = 31;

           if(yue==4 || yue==6 ||yue==9 ||yue==11)

           {

                  n = 30;

           }

           else if(yue==2)

           {

                  n=28;

           }

          

           //用循环添加

           var s = "";

           for(var i=1;i<n+1;i++)

           {

                  if(i==tian)

                  {

                         s +="<option selected='selected'>"+i+"</option>";

                  }

                  else

                  {

                         s +="<option>"+i+"</option>";

                  }

           }

          

           document.getElementById("day").innerHTML = s;

          

    }

    </script>

    </html>

  • 相关阅读:
    获得SQL语句的模板,自己写类似readtrace时候用
    我的HD2手机
    匹配symbols
    再送一次书
    微软急聘MOSS高手!
    邮件规则的实现
    System.Data.SQLClient.SqlConnection在Open之后为什么需要及时Close?
    windbg中无法加载mscorwks.dll, Win32 error 0n2
    Diablo3狗熊榜
    软件构架师的特点
  • 原文地址:https://www.cnblogs.com/sq45711478/p/5899143.html
Copyright © 2020-2023  润新知