473,796 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.c ount
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("u pdateTable") <> "" then
For Each Item In Request.Form
x = Item
y = Request.Form(It em)
Response.Write "Item: " & X & " - " & Y & "<br/>"
Next

'############## ############### ##
'##### Unfinised SQL Query #####
SQL = "INSERT INTO '" & updateTable & "' SET "
'############## ############### ##

End If

if Request.Form("t able") = "" then

Else
Response.Write "<br/><br/>"
tablename = Request.Form("t able")

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=""updateTa ble"" 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 7306
If Request.Form("u pdateTable") <> "" then
For Each Item In Request.Form
x = Item
y = Request.Form(It em)
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******** ******@TK2MSFTN GP10.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.c ount
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("u pdateTable") <> "" then
For Each Item In Request.Form
x = Item
y = Request.Form(It em)
Response.Write "Item: " & X & " - " & Y & "<br/>"
Next

'############## ############### ##
'##### Unfinised SQL Query #####
SQL = "INSERT INTO '" & updateTable & "' SET "
'############## ############### ##

End If

if Request.Form("t able") = "" then

Else
Response.Write "<br/><br/>"
tablename = Request.Form("t able")

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=""updateTa ble"" 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
2408
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 Session object gets set fine. But when the user links to another page, the value of the session object is EMPTY. thanks in advance..
18
2107
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 id=f2 value=val2> <input type=submit value="Choose Me"> </form>
10
2597
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 = malloc(sizeof(*arr) * 4); /* I want to dynamically allocate
2
2313
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 menu dissappears. Any one know why? Below is the code I'm using to create the menu items and append them to the existing menu: Dim aDatasheets As ArrayList = gOSSystemFile.Datasheets
2
3451
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 can not use the row 0, and the column 0.
1
1616
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 combo boxes on my form and I want to put the into an array. Can someone point me to some good guide on how to do it or posibly post 'how to' ? Thanks in advance.
2
1132
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 id, method and action set. The fields have ids, but when I do something like: String avar = Request;
9
2790
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 retains the value of the previously submitted value. How would one do that? TIA. I was thinking something along this line but not sure it's the right way to accomplish this task
3
2676
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
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.