[求助] 一个自动倒数的问题
我想做个简单的在线测试系统,从数据库中提取10道试题,(都是单选题,每页一题)每道题只能在指定的秒数内做出选择,否则自动跳至下一题。
现在的问题是,怎样在这个页面上倒计秒数?用JavaScript吗?
望高手指教:
我写了点简易代码如下(页页效果及说明如后面附件图片):
<table width="400" border="0" align="center">
<tr>
<td height="35">
<p align="left">第10题:下列颜色中,你最喜欢哪一颜色?</p></td>
</tr>
<tr>
<td>
<form name="form1" method="post" action="">
<P><input type="radio" name="radiobutton" value="radiobutton">红或橘色</P>
<P><input type="radio" name="radiobutton" value="radiobutton">黄或浅蓝色</P>
<P><input type="radio" name="radiobutton" value="radiobutton">绿色</P>
<P><input type="radio" name="radiobutton" value="radiobutton">棕或灰色</P>
</form>
</td>
</tr>
<tr>
<td height="31">
<a href=test.asp?page="&page+1&">下一题</a>(还剩:<span class="style2">xx</span>秒自动转至下一题)
</td>
</tr>
</table>
需要时间跳到下一题很简单,但首先要知道一共有多少题,然后for (i=0;i [/quote]
版主能来说得具体点?
贴出主要代码更佳,不甚感激! [code]<script>
function createtime(){
var page=document.getElementById("page");
var timetxt=document.getElementById("timetxt");
var miao=parseInt(timetxt.innerHTML)-1;
if(miao==0){location.href="?page="+page+1;}else{timetxt.innerHTML=miao;}
}
setInterval("createtime()",900);
</script>
<input type="hidden" id="page" value="<%=page%>" />
还剩:<span id="timetxt" style="color:red;">10</span> 秒自动转至下一题[/code] [quote][bo][un]hmhz[/un] 在 2008-6-17 12:05 的发言:[/bo]
function createtime(){
var page=document.getElementById("page");
var timetxt=document.getElementById("timetxt");
var miao=parseInt(timetxt.innerHTML)-1;
if(miao==0){location.href="?page="+pag ... [/quote]
还得麻烦版主:
为何我用进去后可以看到秒数在倒数,但到0的时候就是跳不到下一页去?
在地址栏看到的跳转地址是...test.asp?page=[object]
我把原代码传上来了,麻烦帮我看看!
Thanks <script>
function createtime(){
var page=document.getElementById("page");
var timetxt=document.getElementById("timetxt");
var miao=parseInt(timetxt.innerHTML)-1;
if(page=="[object]"){var pages=0;}else{var pages=page;}
if(miao==0){location.href="?page="+pages+1;}else{timetxt.innerHTML=miao;}
}
setInterval("createtime()",900);
</script> 这问题还真奇怪了,版主给的方法还是达不到理想效果,
让我再仔细研究一下吧,
多谢hmhz版主的指教! <html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv=refresh content=10;url="转向的下一页地址">
<head>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td height="25" align="center" bgcolor="#DDDDDD"><b><font color="#187A4B">== 成功信息 ==</font></b></td>
</tr>
<tr>
<td height="80" valign="top" bgcolor="#F5F5F5"><span id="yu">10</span><a href="javascript:countDown"></a> 秒钟后系统将自动转到下一题...</b></td></tr>
<tr>
<td height="22" bgcolor="#DDDDDD"><div align="center">
</div></td>
</tr>
</table>
<script>function countDown(secs){yu.innerText=secs;if(--secs>0)setTimeout("countDown("+secs+")",1000);}countDown(10);</script>
页:
[1]
