473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamically add posted form items into array

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
1 7286
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Brian Burgess | last post by:
Hi all, Anyone know of any issues with setting the value of a Session object to the value of a submitted form item via 'Session("mySessionObj")=Request.Form("myFrmElem")' ? In my case the...
18
by: Choxio | last post by:
Using ASP you can access posted form elements. Is it possible to access them from JavaScript? myHTML.htm <form action=myASP.asp> <input type=hidden id=f1 value=val1> <input type=hidden...
10
by: junky_fellow | last post by:
What is the correct way of dynamically allocating a 2d array ? I am doing it the following way. Is this correct ? #include <stdlib.h> int main(void) { int (*arr)(3); arr =...
2
by: jack | last post by:
Hello, I need to dynamically add menu items to an existing menu on an MDI form. In the form load, when I create the menu items then add it to the menu control using the Add method, the entire...
2
by: xhunga | last post by:
I have try a new version of my work. I have put the sizes of the matrix into the matrix. A = number of rows A = number of columns The first element of the matrix is A instead of A. You...
1
by: Vanyok | last post by:
Hi everyone :) I'm a newb to C-Sharp but more I learn about it - more I like it. I need some help please. I'm trying to find out to dynamically allocate form controls. For example I want to have 5...
2
by: Waldy | last post by:
Hi there, I have a pure HTML form that is submitting data back to an ..ASPX form. However, when I try to read the field values from the Request object, the values are not there. The Form has...
9
by: student4lifer | last post by:
Hello, could someone show me how to make sticky form with dynamically generated form element? for example, if one likes to make the dynamically generated check box (and its name) 'sticky' that...
3
by: sherman | last post by:
string ***dat_array; int t; dat_array = new string **; for (i=0; i<t; i++) { dat_array = new string *; for (j=0; j<5; j++) dat_array = new string ; } // dat_array = new string **;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.