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>
    

      

  • 相关阅读:
    Mysql基本操作、C++Mysql简单应用、PythonMysql简单应用
    Mysql安装步骤
    MVC EF 移除建表时自动加上s的复数形式
    MVC autofac 属性注入
    layui table默认选中指定行
    js slice 假分页
    sql 根据身份证号码计算年龄
    pointer-events: none
    /Date(1555554794000)/ 转换为日期格式
    sql 查询字段如果为null 则返回0的写法
  • 原文地址:https://www.cnblogs.com/batter152/p/4369280.html
Copyright © 2011-2022 走看看