|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dynamically add posted form items into array
database table its calling. Therefore, the number of category.name.count can be different. So I have this form generated and say with x amount of input boxes.. I enter data in the boxes and submit. The data submitted is needing to be placed into an array for insert into a database. The code I have so far is this: <% Response.Write ("Form Data: " & Request.Form & "<br/>") If Request.Form("updateTable") <> "" thenFor Each Item In Request.Form x = Item y = Request.Form(Item) Response.Write "Item: " & X & " - " & Y & "<br/>" Next'############################### '##### Unfinised SQL Query ##### SQL = "INSERT INTO '" & updateTable & "' SET " '############################### End If if Request.Form("table") = "" then Else Response.Write "<br/><br/>" tablename = Request.Form("table") Call OpenDB() SQL = "SELECT * FROM tbl" & tablename Set RS = CN.Execute(SQL) Response.Write "<form method=""post"" action=""index.asp"">" Response.Write "<input type=""submit"" value=""Submit"" name=""B1"">" & vbCrLf Response.Write "<input type=""hidden"" name=""updateTable"" value=""tbl" & tablename & """ />" & vbCrLf Response.Write "<table border=""1"" cellpadding=""5"">" & vbCrLf Response.Write "<tr>" & vbCrLf for each Category in RS.fields Response.Write "<td><b>" & Category.name & "</b></td>" & vbCrLf col = Rs.Fields.Countnext Response.Write "</tr>" & vbCrLf Response.Write "<tr>" & vbCrLf for each Category in RS.fields Response.Write "<td><input type=""text"" name=""" & Category.name & """ size=""20"" /></td>" & vbCrLf next Response.Write "</tr>" & vbCrLf If RS.EOF Then Response.Write "<tr>" & vbCrLf Response.Write "<td colspan=""" & col & """ align=""center"">" & vbCrLf Response.Write "No records matched!<br/> Number of Fields: " & col Response.Write "</td>" & vbCrLf Response.Write "</tr>" & vbCrLf Response.Write "</table>" & vbCrLf Response.Write "</form>" Else alldata = RS.GetRows End If Call CloseDB() %> Im kinda lost as to how to get the form data into an array where I can do my SQL query... *** Sent via Developersdex http://www.developersdex.com *** If Request.Form("updateTable") <> "" then
For Each Item In Request.Form x = Item y = Request.Form(Item) If Len(arrItems) > 0 Then arrItems = arrItems & ",," & X & " - " & Y '// Seperate with double comma Else arrItems = X & " - " & Y '// Seperate with double comma End If Next Show quote "Daniel Gormley" <dan***@iqcrew.net> wrote in message news:OV$ihiEAGHA.2092@TK2MSFTNGP10.phx.gbl... > What I have is a form that is dynamically generated based on which > database table its calling. Therefore, the number of category.name.count > can be different. > > So I have this form generated and say with x amount of input boxes.. I > enter data in the boxes and submit. > > The data submitted is needing to be placed into an array for insert into > a database. > > The code I have so far is this: > > <% > Response.Write ("Form Data: " & Request.Form & "<br/>") > > If Request.Form("updateTable") <> "" then > For Each Item In Request.Form > x = Item > y = Request.Form(Item) > Response.Write "Item: " & X & " - " & Y & "<br/>" > Next > > '############################### > '##### Unfinised SQL Query ##### > SQL = "INSERT INTO '" & updateTable & "' SET " > '############################### > > End If > > if Request.Form("table") = "" then > > Else > Response.Write "<br/><br/>" > tablename = Request.Form("table") > > Call OpenDB() > > SQL = "SELECT * FROM tbl" & tablename > Set RS = CN.Execute(SQL) > Response.Write "<form method=""post"" action=""index.asp"">" > Response.Write "<input type=""submit"" value=""Submit"" name=""B1"">" & > vbCrLf > Response.Write "<input type=""hidden"" name=""updateTable"" value=""tbl" > & tablename & """ />" & vbCrLf > Response.Write "<table border=""1"" cellpadding=""5"">" & vbCrLf > Response.Write "<tr>" & vbCrLf > > for each Category in RS.fields > Response.Write "<td><b>" & Category.name & "</b></td>" & vbCrLf > next > > col = Rs.Fields.Count > > Response.Write "</tr>" & vbCrLf > Response.Write "<tr>" & vbCrLf > > for each Category in RS.fields > Response.Write "<td><input type=""text"" name=""" & Category.name & """ > size=""20"" /></td>" & vbCrLf > next > Response.Write "</tr>" & vbCrLf > > If RS.EOF Then > Response.Write "<tr>" & vbCrLf > Response.Write "<td colspan=""" & col & """ align=""center"">" & vbCrLf > Response.Write "No records matched!<br/> Number of Fields: " & col > Response.Write "</td>" & vbCrLf > Response.Write "</tr>" & vbCrLf > Response.Write "</table>" & vbCrLf > Response.Write "</form>" > Else > alldata = RS.GetRows > End If > Call CloseDB() > %> > > Im kinda lost as to how to get the form data into an array where I can > do my SQL query... > > *** Sent via Developersdex http://www.developersdex.com *** |
|||||||||||||||||||||||