28,391
社区成员
发帖
与我相关
我的任务
分享
<FORM name=myform>剩余时间: <INPUT class=text2 size=10 value=剩余时间
name=clock> <INPUT type=hidden size=50 name=times>
<%
Session("tryTime")="2008/9/9 09:50:00" '这里必须是设定的一个时间,你可以是在登陆的时候设置
TimeGet=Session("tryTime")''这是ASP控制的时间
%>
<SCRIPT language=JavaScript>
var id, iM = 0, iS = 1;
var start1 ="<%=TimeGet%>";
var start=new Date(start1)
if (document.myform.times.value==""){
starts=start.getTime();
}else{
starts=document.myform.times.value;
}
//document.myform.clock.value=start.getSeconds();
function go()
{
now = new Date();
time = (2700000-(now.getTime()-starts))/1000;
//time = (10000-(now.getTime()-starts))/1000;
time = Math.floor( time);
iS = time % 60;
iM = Math.floor( time / 60);
if ( iS < 10){
document.myform.clock.value = " " + iM + ":0" + iS;
}else{
document.myform.clock.value = " " + iM + ":" + iS;
}
document.myform.times.value =starts;
if (time==300){
alert("请抓紧时间答题,距交卷还有5分钟。");
}
if (time==0){
alert("时间到,请交卷。");
window.location="test.asp?gopage=jiaojuan&choose=" + document.form1.choose.value;
}
id = setTimeout( "go()", 1000);
}
go();
</SCRIPT>
</form>