用js实现倒记时
              

<%@ page contentType="text/html;charset=GB2312" %>
<%@ include file=
"javabean/useBean.jsp"%>

<!--控制二次提交的js start-->
<script language=
"JavaScript" type="text/javascript">

function submitQuest(frm){
var allselected=0;
var needSelectCount=1

if (frm.refer_flag.value==
"Y"){
alert(
"您已经提交过一次答案!请重新开始一组题!");
return false;
}else{
frm.timeout_flag.value=1;
if(frm.refer_flag.value!=
"Y"){
if(frm.remain_time.value<=0){
frm.timeout_flag.value=0;
}else{
frm.timeout_flag.value=1;
}
frm.refer_flag.value=
"Y";
frm.submit();
return true;
}
}
}
</script>
<!--控制二次提交的js end-->
<%
  
String classId=request.getParameter(
"classId");

%>

<form name=
"actionfrm" id="actionfrm" method="post" action="doquest.jsp">
<p>
  <input type=
"hidden" name="timeout_flag">
  <input type=
"hidden" name="refer_flag" >
  <script language=
"JavaScript" type="text/javascript">
function reflash_page(){
if (document.actionfrm.refer_flag.value==
"Y")
window.location.href = window.location.href;
}
reflash_page();
</script>

<!--控制时间的(到计时)开始-->
  <input type=
"text" name="remain_time" readonly size="3" value="120" style="color:#AC1605;height:18px;border:0px;font-size:14px">
    秒</p>
<p>
<script language=
"JavaScript" type="text/javascript">
function time_step(){
var frm = document.actionfrm;
var r = frm.remain_time;
if(r.value<=1){
r.value=0;
alert(
"用户您好!规定完成答题的时间已到!系统将自动提交您的答案。");
submitQuest(frm);
}
if (frm.refer_flag.value!=
"Y")
r.value=(r.value!=0)?r.value-1:0;

window.setTimeout(
"time_step()",1000);
}
time_step();
</script>
<!--控制时间的(到计时)结束-->
    
<img src=
"img/dti2.jpg" width="115" height="28" onClick="submitQuest(document.actionfrm);"/></p>


      
lunzi   2006-08-03 23:36:01 评论:2   阅读:1942   引用:0
@2007-01-02 13:10:11  lunzi
谢谢! 好人一生平安
新年快乐 @2007-01-02 09:52:56  air_tuyh
新年快乐,心想事成哦!!

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

认证码: (如不清楚,请刷新)


Copyright@2004-2010 powered by YuLog