zoukankan      html  css  js  c++  java
  • js实例8日期的选择

    <body>

    <select id="nian" onclick="biantian()"></select>年
    <select id="yue" onclick="biantian()"></select>月
    <select id="tian"></select>日

    <script type="text/javascript">
    FillNian();
    FillYue();
    FillTian();
    function FillNian()
    {
    var b = new Date(); //获取当前时间
    var nian = parseInt(b.getFullYear());

    var str = "";

    for(var i=nian-5;i<nian+6;i++)
    {
    str = str+"<option value='"+i+"'>"+i+"</option>";
    }

    document.getElementById("nian").innerHTML = str;

    }

    function FillYue()
    {
    var str = "";
    for(var i=1;i<13;i++)
    {
    str = str+"<option value='"+i+"'>"+i+"</option>";
    }
    document.getElementById("yue").innerHTML = str;
    }

    function FillTian()
    {
    var yue = document.getElementById("yue").value;
    var nian = document.getElementById("nian").value;
    var ts = 31;

    if(yue==4 || yue==6 || yue==9 || yue==11)
    {
    ts=30;
    }

    if(yue==2)
    {
    if((nian%4==0 && nian%100 != 0) || nian%400==0)
    {
    ts = 29;
    }
    else
    {
    ts = 28;
    }
    }

    var str = "";
    for(var i=1;i<ts+1;i++)
    {
    str = str+"<option value='"+i+"'>"+i+"</option>";
    }
    document.getElementById("tian").innerHTML = str;



    }


    function biantian()
    {
    FillTian();
    }
    </script>
    </body>

  • 相关阅读:
    hystrix总结之缓存
    python3列表
    hystrix总结之多返回值命令
    hystrix总结之限流
    hystrix(5) 延时检测
    redis-start
    设计模式-4建造者模式
    设计模式-3原型模式
    设计模式-2工厂设计模式
    设计模式-七大设计原则
  • 原文地址:https://www.cnblogs.com/qdlj/p/6188503.html
Copyright © 2011-2022 走看看