By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Dynamically add posted form items into array

P: n/a
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 ***
Dec 14 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Daniel Gormley" <da****@iqcrew.net> wrote in message
news:OV**************@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 ***

Dec 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.