• 计算星期几


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <tr>
                <td>请输入年:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                <td><input type="text" id="year" value=""/></td>
            </tr>
            <br>
            <tr>
                <td>请输入月:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                <td><input type="text" id="month" value=""/></td>
            </tr>
            <br>
            <tr>
                <td>请输入日:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                <td><input type="text" id="date" value=""/></td>
            </tr>
            <br>
            <tr>
                <td>请输出星期几:</td>
                <td><input type="text" id="day"/></td>
            </tr>
            <br>
            <tr>
                <td><input type="button" value="计算" id="btn"/></td>
                <td><input type="button" value="清空" id="res"/></td>
            </tr>
        </body>
    </html>
    <script>
        var oYear = document.getElementById( "year" );
        var oMonth = document.getElementById( "month" );
        var oDate = document.getElementById( "date" );
        var oBtn = document.getElementById( "btn" );
        var oDay = document.getElementById( "day" );
        var oRes = document.getElementById( "res" );
        oBtn.onclick = function(){
    var m = parseInt( oMonth.value );
    var y = parseInt( oYear.value );
    var d = parseInt( oDate.value );
     
            var sum = 0;
             switch( m ){
                    case 12 : sum += 30;//11月
                    case 11 : sum += 31;
                    case 10 : sum += 30;
                    case 9 : sum += 31;
                    case 8 : sum += 31;
                    case 7 : sum += 30;
                    case 6 : sum += 31;
                    case 5 : sum += 30;
            
                    case 4 : sum += 31; //3月
                    case 3 : {
                        y%4==0&&y%100!=0||y%400==0 ? sum += 29 : sum += 28;
                    }
                    case 2 : sum += 31; // 1月
                    case 1 : sum += d;
                }
            
             if( sum%7 == 0 ){
                oDay.value = "星期天"
             }else if( sum%7 == 1 ){
                oDay.value = "星期一"
             }else if( sum%7 == 2 ){
                oDay.value = "星期二"
             }else if( sum%7 == 3 ){
                oDay.value = "星期三"
             }else if( sum%7 == 4 ){
                oDay.value = "星期四"
             }else if( sum%7 == 5 ){
                oDay.value = "星期五"
             }else if( sum%7 == 6 ){
                oDay.value = "星期六"
             }
            
        }
        oRes.onclick = function(){
            oYear.value="";
            oMonth.value="";
            oDate.value="";
            oDay.value="";
        
        }
        
    </script>
    <!-- alert( sum );-->
  • 相关阅读:
    openswitch db files
    openstack中虚拟机和其网络的联系方法 instance and network
    python操作db2和mysql ,ibm_db
    yum安装mariadb
    python 连接 db2
    db2操作 连接、备份、恢复db2
    su su
    linux 后台运行进程 fg bg ctrl+z nohup
    mysql 命令行
    IDEA-使用技巧
  • 原文地址:https://www.cnblogs.com/tis100204/p/10328818.html
Copyright © 2020-2023  润新知