标题:请问如何将JavaScript写的倒记时代码加到下面的代码中
只看楼主
leesunmoo
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-3-19
 问题点数:0 回复次数:0 
请问如何将JavaScript写的倒记时代码加到下面的代码中
<% @ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<Script runat="server">
string Lesson;
string No;
string Name;
OleDbDataReader dr;
void Page_Load(Object Src, EventArgs E) {
Lesson = Request["Lesson"];
No = Request["No"];
Name = Request["Name"];
string SQL = "Select * From " + Lesson + " Order By 题号";
OleDbConnection Conn;
建立新数据库联结Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+
"Data Source="+Server.MapPath("test.mdb"));
Conn.Open();
//Response.Write(SQL);
OleDbCommand Comm = new OleDbCommand(SQL,Conn);
dr = Comm.ExecuteReader();
}
</Script>
<HTML>
<BODY BGCOLOR=BEIGE>
<CENTER>
<H1><FONT COLOR=#6699DD>在线考试系统</FONT></H1>
</CENTER>
<H2>考试科目 -- <%=Lesson%><HR></H2>
<FORM Action="Score.aspx" Method="GET">
<INPUT Type="Hidden"隐藏域 作为表单内容提交Name="Lesson" Value=<%=Lesson%>>
<INPUT Type="Hidden" Name="No" Value=<%=No%>>
<INPUT Type="Hidden" Name="Name" Value=<%=Name%>>
<%
string TestType = "";
while (dr.Read()){
Response.Write输出显示的内容("<B>" + dr["题号"].ToString() + "."
+ Server.HtmlEncode(dr["题目"].ToString())
+ dr["类型"].ToString() + ":" + dr["分数"].ToString() + "分)</B>");
Response.Write("<div>");
for (int i=1; i<5; i++) {
if (dr["类型"].ToString() == "单选") {
TestType = "Radio";
}
else {
TestType = "CheckBox";
}
Response.Write("<INPUT Type=" + TestType
+ " Name=No" + dr["题号"].ToString()
+ " Value=" + i +">"
+ Server.HtmlEncode(dr["选项" + i].ToString()) + "<BR>");
}
Response.Write("</div>");
}
%>
<INPUT Type=Submit 指定符号类型为提交按扭Value=" 交 卷 ">
</FORM><HR></BODY>
</HTML>



用JavaScript编的到记时
html>
<head>
<title>自动交卷</title>
<script language="Javascript">
var timer = 200; //在这里设定考试时间,单位为秒。
var startTime, timeOver
function checkTime()
{
var timeNow = new Date();
var remnantTime = timeOver.getTime() - timeNow.getTime();
if(remnantTime < 1)
{
alert("时间到了,点击确定交卷。");
document.myFrm.submit();
}
else
{
var msg = "";
remnantMinutes = Math.round(remnantTime/60000);
remnantSeconds = Math.round((remnantTime % 60000) / 1000)
if(remnantMinutes > 0 ) msg = remnantMinutes + "分钟";
msg += remnantSeconds + "秒";
label1.innerText = msg;
}
setTimeout("checkTime();",1000);
}
function window_load()
{
startTime = new Date();
timeOver = new Date()
timeOver.setTime(startTime.getTime() + (timer * 1000));
checkTime();
}
window.onload = window_load; //网页加载完成开始计时
</script>
</head>
<body>
离交卷还有:<span id="label1"></span>
<form name="myFrm" action="result.asp" style="border:1 solid #CCCCCC" title="这是试题的表单">
姓名:<input type="text" name="Name"><br>
考号:<input type="text" name="Number"><br>
<input type="submit" value="交卷">
</form>
</html>
搜索更多相关主题的帖子: JavaScript 记时 代码 
2006-03-23 09:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-52180-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.402746 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved