• 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>

  • 相关阅读:
    SyntaxError: Non-ASCII character 'xe7' in file解决方法
    python实现微信打飞机游戏
    ubuntu 系统出错一览
    MVC的特点
    架构
    策略模式
    bin
    使用XSLT实现Word下载
    <a>标签的href属性
    call-template和apply-templates
  • 原文地址:https://www.cnblogs.com/qdlj/p/6188503.html
Copyright © 2020-2023  润新知