求助在线考试系统,倒计时提交js代码!

hu_hai 2012-08-14 03:40:56
求助在线考试系统,倒计时提交js代码! 详细点,谢谢!!
...全文
823 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lip009 2012-08-15
  • 打赏
  • 举报
回复

<form id="frm" action="http://www.baidu.com">
考试还剩余<div id="time"></div>
</form>
<script>
var times = 45 * 60;//剩余时间,单位秒
var timeDiv = document.getElementById("time");
var timeObj = null;
function timer(){
if(times == 0){
//倒计时结束,提交表单
document.getElementById("frm").submit();
window.clearInterval(timeObj);
return;
}
var t = Math.floor(times/60) +"分"+times%60+"秒"
timeDiv.innerHTML = t;
times --;
}
timeObj = window.setInterval(timer,1000);
</script>
S1412801460 2012-08-15
  • 打赏
  • 举报
回复
那写上表单提交撒sumit()[Quote=引用 7 楼 的回复:]
引用 6 楼 的回复:

<html>
<head>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
</head>

<script>
var i=10;
function al(){
i--;
if(i>=0)
setTimeout(function(){
$('#exam').…………
[/Quote]
S1412801460 2012-08-15
  • 打赏
  • 举报
回复
<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.min.js"></script>
<style type="text/css">
body {
font: normal 12px verdana;
margin: 0;
background-color: #E7ECF1;
text-align: center;
}
</style>
<script type="text/javascript">
var count = 10;
setTimeout(function() {
window.location.href = "login.jsp";
}, 10000);
setInterval(function() {
count --;
$("#count").text(count+"");
},1000);
</script>
</head>
<body>
<div style="color:red;padding-top:15%;" id="error">
error:内部服务器出错!<br/>
10秒后自动返回登录页面:<br/>
请等待:<span id="count">10</span>......
</div>
</body>
</html>

hu_hai 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

<html>
<head>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
</head>

<script>
var i=10;
function al(){
i--;
if(i>=0)
setTimeout(function(){
$('#exam').……
[/Quote]兄弟你误会我的意思了,是考试系统,到了时间自动提交表单,不是点击提交按钮后几秒提交
ZHOU西口 2012-08-15
  • 打赏
  • 举报
回复
<html>
<head>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
</head>

<script>
var i=10;
function al(){
i--;
if(i>=0)
setTimeout(function(){
$('#exam').html('No.'+i);
al();
},1000);
if(i==0){
$('body').load('你的新地址url');
}
}
</script>
<body>
<div id="exam">倒计时准备</div><button onclick=al()>开始</button>

</body>
</html>
hu_hai 2012-08-14
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

可以这样写:
--------------------------定义一个div
<div id='time'>倒计时正式开始</div>

--------------------------倒计时脚本
<script>
var count = 10;
while(count>=0){
jQuery('#time').html('第'+count+……
[/Quote]能给详细的代码吗?谢谢
ZHOU西口 2012-08-14
  • 打赏
  • 举报
回复
可以这样写:
--------------------------定义一个div
<div id='time'>倒计时正式开始</div>

--------------------------倒计时脚本
<script>
var count = 10;
while(count>=0){
jQuery('#time').html('第'+count+'秒');
count--;
}
</script>
hu_hai 2012-08-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

javascript:是这样的吗?------------------

var count = 10;
function event(){
count--;
if(count==0){
window.location.href='your url';
}
}
[/Quote] 对啊,类似的,要在jsp页面上显示剩余的时间
ZHOU西口 2012-08-14
  • 打赏
  • 举报
回复
javascript:是这样的吗?------------------

var count = 10;
function event(){
count--;
if(count==0){
window.location.href='your url';
}
}
i_hate_you7452 2012-08-14
  • 打赏
  • 举报
回复
我是不会写了。。百度一搜一堆

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧