考试系统中的倒计时(JavaScript)
<script type="text/javascript">
var myTimeOut=document.forms[0].txtLimt.value*1;
var sec=30;
window.attachEvent("onload",myTimer);
function myTimer(){
if(sec==00)
{
sec=59;
myTimeOut-=1;
}
else
{
sec-=1;
}
document.forms[0].RemainTime.value=myTimeOut+":"+sec;
if(myTimeOut==0&&sec==0)
{
document.getElementById("ibtOver").click();
}
window.setTimeout("myTimer()",1000);
}
</script>
var myTimeOut=document.forms[0].txtLimt.value*1;
var sec=30;
window.attachEvent("onload",myTimer);
function myTimer(){
if(sec==00)
{
sec=59;
myTimeOut-=1;
}
else
{
sec-=1;
}
document.forms[0].RemainTime.value=myTimeOut+":"+sec;
if(myTimeOut==0&&sec==0)
{
document.getElementById("ibtOver").click();
}
window.setTimeout("myTimer()",1000);
}
</script>