如何提交动态表单中的多个数据?
从一个数据库读出满足条件的记录,将每个记录的每个字段下的数值放到表单(这里的表单是根据记录动态变化的)里去供用户修改,然后按提交按钮添加到新的数据库中这个问题如何解决(关键是这个问题不会),希望各位高手帮忙顺便给出注释。谢了先!
部分代码如下:
<form action= "savescore.asp " method= "post ">
<table width= "380 " border= "1 " align= "center " >
<tr>
<td align= "center "> 学号 </td>
<td align= "center "> 姓名 </td>
<td align= "center "> 分数 </td>
</tr>
<%do while not rs.eof%>
<tr>
<td align= "center "> <%=rs( "studyid ")%> </td>
<td align= "center "> <%=rs( "yourname ")%> </td>
<td align= "center "> <input type= "text " name= "psscore " value= " <%=rs( "psscore ")%> " size= "8 "> </td>
</tr>
<%
rs.movenext
loop
%>
<tr> <td align= "center " colspan= "3 "> <input type= "hidden " name= "courseid " value= " <%=courseid%> "> <input type= "submit " value= "录入 "> </td> </tr>
</table>
</form>
savescore.asp里的代码应该如何写?
希望各位高手给个思路!
------解决方案--------------------提交页多加一个隐藏域:
<input type= "text " name= "psscore " value= " <%=rs( "psscore ")%> " size= "8 "> <input type= "hidden " name= "studyid " value= " <%=rs( "studyid ")%> ">
处理页:
dim studyid,idArr,psscore,psscoreArr
dim i
dim rs,sql
studyid=request.form( "studyid ")
psscore=request.form( "psscore ")
studyidArr=int(trim(split(studyid, ", ")))
psscoreArr=int(trim(split(psscore, ", ")))
for i=0 to ubound(studyidArr)
conn.execute( "insert into tableName(studyid,psscore) values( "&studyidArr(i)& ", "&psscore& ") ") '插入
'conn.execute( "update tableName set psscore= "&pscore& " where studyid= "&studyidArr(i) ") '更新
next
这是个简单的处理过程,详细的可以自己再稍微增加些