非常感谢,可是我实施起来,遇到问题,提交表单参数不知如何传递,是随机抽取的题目。
我的试题库格式是:
ID timu A B C D answer beizhu
代码如下:不知道我这样的思路对不对?form的action那块
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>考试系统</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 1px;
margin-right: 0px;
margin-bottom: 1px;
text-align: center;
}
.STYLE1 {
font-family: "宋体";
font-size: 24px;
}
-->
</style></head>
<body>
<form id="form1" name="form1" method="post" action="tijiaodaan.asp?id=<%=request("id")%>&radiogroup">
<p> </p>
<table width="700">
<tr>
<td align="left"> </td>
<td align="right"><a href="tianjia.asp" target="_blank">添加新题</a></td>
</tr>
</table>
<br />
<table width="317" height="21">
<tr>
<td width="309"><span class="STYLE1">在线考试系统</span></td>
</tr>
</table>
<br />
<table width="820" border="0" align="center" cellspacing="0" bgcolor="#000000">
<tr>
<td width="54" height="50" align="center" bgcolor="#FFFFFF">序号</td>
<td height="50" colspan="8" align="center" bgcolor="#FFFFFF">题目</td>
<td width="83" align="center" bgcolor="#FFFFFF">修改</td>
</tr>
<%
'查询考试题库开始
counter=1 '序号
set rs1=server.CreateObject("adodb.recordset")
sqlstr1="select * from tiku "
rs1.open sqlstr1,conn,1,1
Dim Appeared
Call DisRndRecord(5,rs1.recordCount) '调用函数该位置显示记录,显示记录数为5,随即抽5道题
'#DisRndRecord(DisNum,rsBound)
'#参数DisNum:显示数量
'#参数rsBound:随机数产生范围
Sub DisRndRecord(DisNum,rsBound)
Dim i,ThisRnd
If rsBound < DisNum Then DisNum = rsBound '记录总数小于要抽取记录条数的情况
For i = 0 To DisNum - 1
ThisRnd = GetRnd(rsBound) '取得一个不重复的随机数
rs1.Move(ThisRnd) '游标指针移动到随机数位置数读取
Response.Write("("&rs1("id")&")")
'下面通过不带边框的表格输出试题
%>
<tr>
<td width="54" height="50" align="center" bgcolor="#FFFFFF"><%=counter%></td>
<td height="50" colspan="9" align="left" bgcolor="#FFFFFF"><%=rs1("timu")%></td>
</tr>
<tr>
<td width="54" height="50" bgcolor="#FFFFFF"></td>
<td width="54" height="50" bgcolor="#FFFFFF">
<!--通过循环产生下面不同name单选组,实现每道题选择的互不干涉,否则所有题只能选择一个选项-->
<label>
<input type="radio" name="RadioGroup<%=counter%>" value="a" id="RadioGroup1_0" />
A.</label></td>
<td width="103" height="50" align="left" bgcolor="#FFFFFF"><%=rs1("a")%></td>
<td width="54" height="50" bgcolor="#FFFFFF"><label>
<input type="radio" name="RadioGroup<%=counter%>" value="b" id="RadioGroup1_1" />
B.</label></td>
<td width="103" height="50" align="left" bgcolor="#FFFFFF"><%=rs1("b")%></td>
<td width="54" height="50" bgcolor="#FFFFFF"><label>
<input type="radio" name="RadioGroup<%=counter%>" value="c" id="RadioGroup1_2" />
C.</label></td>
<td width="103" height="50" align="left" bgcolor="#FFFFFF"><%=rs1("c")%></td>
<td width="54" bgcolor="#FFFFFF"><label>
<input type="radio" name="RadioGroup<%=counter%>" value="d" id="RadioGroup1_3" />
D.</label></td>
<td width="103" height="50" align="left" bgcolor="#FFFFFF"><%=rs1("d")%></td>
<td width="83" height="50" align="center" bgcolor="#FFFFFF"><a href="ajxiugai.asp?id=<%=rs1("id")%>" target="_blank">修改</a></td>
</tr>
<%
counter=counter+1
rs1.Move(-ThisRnd)
Next
End Sub
'函数GetRnd(bound)返回一个不重复的随机数字
'参数bound:随机范围
Function GetRnd(bound)
Dim ranNum
Randomize()
ranNum=int(bound*rnd)
If Instr(Appeared,"["&ranNum&"]") Then '产生的随机数是否出现过
ranNum = getRnd(bound)
End If
Appeared = Appeared & "["&ranNum&"]" '记录已出现的随机数
GetRnd = ranNum
End Function
rs1.close
set rs1=nothing
'查询考试题库结束 %>
<tr>
<td height="50" colspan="10" align="center" bgcolor="#FFFFFF"><label>
<input type="submit" name="button" id="button" value="提交" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
【 在 force2008 (force) 的大作中提到: 】
: form提交表单时,会把页面上的数据交给后台
: 遍历form里需要检查的答案,对照数据库,算出分数,跳到总分页面
--
FROM 116.114.50.*