[此贴子已经被作者于2005-4-30 9:30:33编辑过]
[此贴子已经被作者于2005-4-30 9:30:33编辑过]
ks.asp文件的内容如下: <html> <head> //原意是想通过调用WebBrowser组件的ExecWB方法保存学生的答卷 <script language="javascript"> funtion save_sj() { document.getElementById("webbrowser").ExecWB(4,1); } </script> <title></title> </head> <body>
<form action="ks_ok.asp" method="post"> //显示试题内容 <table align="center">
<% set conn_str=server.createObject("ADODB.Connection") dbpath_str=server.MapPath("ks_auto.mdb") conn_str.open "driver={microsoft Access driver (*.mdb)};dbq="&dbpath_str %> <% sqlstr3="select * from sj_detail where sj_name='"&session("subject")&"'" set rs3=server.CreateObject("ADODB.Recordset") rs3.Open sqlstr3,conn_str,3,2 i=1 do while not rs3.EOF name1="sel"+cstr(i) name2="rig"+cstr(i) %> <tr><th>题目编号:<th>题目内容:<th>备选答案一:<th>备选答案二:<th>备选答案三:<th>备选答案四:<th>你的选择:<th> <tr> <td><%=i%> <td><%=rs3("item_content")%> <td><%=rs3("item_answer1")%> <td><%=rs3("item_answer1")%> <td><%=rs3("item_answer2")%> <td><%=rs3("item_answer3")%> <td><%=rs3("item_answer4")%> <td><select name=<%=name1%>><option selected>A</option><option>B</option><option>C</option><option>D</option></select> <td><input type="hidden" name=<%=name2%> value="<%=rs3("item_right")%>" </tr> <% i=i+1 rs3.MoveNext loop item_count=i-1 %> <tr rowspan="8" align="center"> <td><input type="submit" value="交卷" id=submit1 name=submit1 onclick="javascript:save_sj();"> </tr> </table> <input type="hidden" name="item_cou" value=<%=item_count%>> </form> //关闭记录集和数据库 <% rs3.close set rs3=nothing conn_str.Close set conn_str=nothing %> <object id="webbrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> </object> </body> </html> ks_ok.asp的内容如下: <% set conn_str=server.createObject("ADODB.Connection") dbpath_str=server.MapPath("ks_auto.mdb") conn_str.open "driver={microsoft Access driver (*.mdb)};dbq="&dbpath_str %>
<% subject_ks_ok=session("subject") stu_name=session("name") //计算考生分数 answer_right_count=0 item_counter=cint(Request.Form("item_cou")) for i=1 to item_counter name1="sel"+cstr(i) name2="rig"+cstr(i) if Request.Form(name1)=Request.Form(name2) then answer_right_count=answer_right_count+1 end if next score=int(answer_right_count/item_counter*100) Response.Write "你的成绩为"+cstr(score) //保存学生成绩到数据库中 sqlstr1="select * from stud_scor where name='"&stu_name&"'" set rs1=server.CreateObject("ADODB.Recordset") rs1.Open sqlstr1,conn_str,3,2 for each objfield in rs1.Fields if objfield.name=subject_ks_ok then objfield.value=score end if next rs1.Update %> //关闭记录集和数据库 <% rs1.Close set rs1=nothing conn_str.Close set conn_str=nothing %> 只要把红色代码去掉,程序运行正确. 可是加入红色代码后,便有VBScript出现了运行时间错误,是否要进行调试:行5 错误:缺少; 这样的出错提示
[此贴子已经被作者于2005-4-30 9:51:19编辑过]