设计好每个input的name属性,然后用For Each re In Request.Form来遍历,组合出语句来。
我写的一段代码:
程序代码:
' 显示表单
Sub ShowTestScoreEdit(TestID,ClassID)
Dim rs,Subjects,i,c
Set rs=Conn.Execute("SELECT * From Ns_Student Where ClassID=" & ClassID & " Order By ShowOrder Asc")
Subjects=Split(Conn.Execute("Select Subject From Ns_Test Where TestID=" & TestID)("Subject"),"|")
%>
<script>
var testid=<%=TestID%>;
var classid=<%=ClassID%>;
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DFDFDF">
<tr bgcolor="#CCCCCC">
<!--<td width="50" height="30"><div align="center"><strong>编号</strong></div></td>-->
<!--<td width="80" height="30"><div align="center"><strong>学号</strong></div></td>-->
<td height="30"><div align="center"><strong>姓名</strong></div></td>
<%
For i=1 to UBound(Subjects)-1
%>
<td width="50" height="30"><div align="center"><strong><%=GetSubjectName(Subjects(i))%></strong></div></td>
<%
Next
%>
</tr>
<%
c=0
Randomize
While Not rs.EOF
c=c+1
%>
<tr align="center" bgcolor="#F5F5F5">
<!--<td height="25"><a href="Student_Show.asp?id=<%=rs("StudentID")%>">S<%=rs("StudentID")%></a></td>-->
<!--<td><%=rs("RegOrder")%></td>--->
<td><%=Encode(rs("StudentName"))%></td>
<%
For i=1 to UBound(Subjects)-1
Response.Write "<td id=""td" & c & "n" & Subjects(i) & """><input style=""width:30px;text-align:center;"" size=""3"" type=""text"" name=""Score" & rs("StudentID") & "n" & Subjects(i) & """ id=""sScore" & c & "n" & Subjects(i) & """ value=""" & GetScore(rs("StudentID"),TestID,Subjects(i)) & """ onkeypress=""jumpto(" & c & "," & Subjects(i) & ",event)"" onchange=""paint(" & c & "," & Subjects(i) & ")""/><script>setTimeout(""paint(" & c & "," & Subjects(i) & ")""," & Int(Rnd*(100)+c*(100)+2000) & ")</script></td>"
Next
%>
</tr>
<%
rs.MoveNext
Wend
%>
</table>
<%
End Sub
程序代码:
'接受数据
<%
Dim s,t
For Each s In Request.Form
If (Left(s,5)="Score") Then
t=Replace(s,"Score","")
t=Split(t,"n") ' StudentID,SubjectID
SaveScore ID,t(0),t(1),Request.Form(s)
Response.Write ". "
Response.Flush
End If
Next
'Response.Write "<br />成绩录入成功!下面转向测试页面"
'Redirect "Test_Show.asp?ID=" & ID
Response.Write "<br />成绩录入成功!下面将对成绩进行排序<script>setTimeout(""MM_showHideLayers('Console','','show')"",300)</script>"
Redirect "Test_Score_Sort.asp?ID=" & ID & "&ClassID=" & ClsID
%>