En uppföljningsfråga på mitt tidigare inlägg... [request.form + flera insert] Detta kanske kan var till någon hjälp?for each fortsättning
<code>
<form method="post" action="tavling.asp?sida=taemotsvar&id=<%=request.querystring("id")%>" name="skickasvar" id="skickasvar">
<%
rs.Close
SQL = "Select runda from tavlingar where id='" & replace(request.queystring("id"),"'","'") & "'"
rs.open SQL, Connect
runda = rs("runda")
rs.close
SQL = "Select * from fragor where tavlingid='" & replace(request.queystring("id"),"'","'") & "' and runda = '" & runda & "'"
rs.open SQL, Connect
Do until rs.EOF
fraga = rs("fraga")
id = rs("id")
%>
<b><%=fraga%></b><br>
<textarea name="<%=id%>" id="<%=id%>"></textarea>
<%
rs.movenext
loop
rs.cose
%>
</form>
</code>
<code>
Dim varTemp
For each varTemp In Request.Form("????")
SQL = "INSERT INTO tavlingfragor(fraga, tavlingid, fragaid) values('" & Replace(varTemp, "'", "''") & "', '" & Replace(request.querystring("id"), "'", "''") & "', '" & ????? & "')"
rs.open SQL, Connect, 1,2
Next
</code>
vill sätta in frågans id i svar databasen samtidigt som jag sätter in svarenSv: for each fortsättning
<code>
rs.Close
%>
<form method="post" action="tavling.asp?sida=taemotsvar&id=<%=request.querystring("id")%>" name="skickasvar" id="skickasvar">
<%
Dim Index
SQL = "SELECT fragor.*" & vbCrLf & _
"FROM Fragor LEFT JOIN Tavlingar ON Fragor.TavlingId = Tavlingar.Id AND Fragor.Runda = Tavlingar.Id" & vbCrLf & _
"WHERE Tavlingar.Id = '" & Replace(Request.Queystring("id"),"'","''") & "'"
rs.Open SQL, Connect
Do Until rs.EOF
Index = Index + 1
Response.Write Server.HTMLEncode(rs("fraga"))
%><br>
<input type=hidden Name="Id<%=Index%>" value="<%=rs("id")%>">
<textarea name="Text<%=Index%>" id="Text<%=Index%>"></textarea>
<%
rs.MoveNext
Loop
rs.cose
%>
<input type=hidden Name="Count" value="<%=Index%>">
</form>
</code>
<code>
Dim Index
Dim strID
Dim strText
Dim strTavlingId
strTavlingId = Request.QueryString("id")
For Index = 1 To CLng(Request.Form("Count"))
strID = Request.Form("Id" & Index)
strText = Request.Form("Text" & Index)
SQL = "INSERT INTO tavlingfragor(fraga, tavlingid, fragaid)" & vbCrLf & _
"VALUES ('" & Replace(strText, "'", "''") & "', '" & Replace(strTavlingId, "'", "''") & "', '" & Replace(strID, "'", "''") & "')"
Connect.Execute SQL
Next
</code>