zoukankan      html  css  js  c++  java
  • 使用JS页面倒计时,时间到了之后提交表单

    使用在在线测试的程序中,使得有倒计时功能,时间到了之后,自动提交内容。
    <style type="text/css"> #remainTime
    { font-size:24px; font-weight:800; color: white; position: fixed; float: right; right: 100px; width: 100px; height: 70px; text-align: center; background-color: #A51257; padding-top: 40px; } </style>

    <script type="text/javascript"> $(document).ready(function () { //这里获取倒计时的起始时间 SysSecond = parseInt($("#remainSeconds").html()); if (SysSecond != "" && !isNaN(SysSecond)) { alert("Please start the test. The test should be completed in 30 minutes."); InterValObj = window.setInterval(SetRemainTime, 1000); //间隔函数,1秒执行 } }); //将时间减去1秒,计算天、时、分、秒 function SetRemainTime() { if (SysSecond > 0) { SysSecond = SysSecond - 1; var second = padLeft(Math.floor(SysSecond % 60),2); // 计算秒 var minite = padLeft(Math.floor((SysSecond / 60) % 60),2); //计算分 //var hour = Math.floor((SysSecond / 3600) % 24); //计算小时 //var day = Math.floor((SysSecond / 3600) / 24); //计算天 $("#remainTime").html(minite + ":" + second); } else { //剩余时间小于或等于0的时候,就停止间隔函数 alert("Time is up."); window.clearInterval(InterValObj); //这里可以添加倒计时时间为0后需要执行的事件 document.getElementById("<%=bt_Submit.ClientID %>").click(); } } //Keep the format function padLeft(str, lenght) { if (str.length >= lenght) return str; else return padLeft("0" + str, lenght); } </script>
    <div runat="server" id="divRemain" Visible="False">
        <div id="remainSeconds" style="display:none">10</div> 
        <div id="remainTime"></div> 
        </div>
    

      

  • 相关阅读:
    oracle的over函数应用(转载)
    Oracle decode()函数应用
    EL表达式显示数据取整问题
    null值与空值比较
    case when语句的应用
    堆排序
    希尔排序
    插入排序
    异或运算
    选择排序
  • 原文地址:https://www.cnblogs.com/batter152/p/4369280.html
Copyright © 2011-2022 走看看