Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2004, 10:08 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tp194
Default Capturing Form values into an Array

Hi, this is probably an easy question to answer, but I'm throughly confused by arrays.

I have a form that is capturing info for up to 5 different vendors. For each vendor, I'm asking for 4 pieces of info (vendor name, alt1, alt2, alt3).

In my database, each alt needs to get put into it's own row, i.e:
Record 1 = vendorName, alt1
Record 2 = vendorName, alt2
Record 3 = vendorName, alt3

I think the best way to caputre this info from the html form is to put the data into an array, but I'm not sure how...

Any suggestions would very much appreciated.

Thanks

Terry

 
Old September 9th, 2004, 03:33 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Yes put the data into an array.You have five different vendors right and also u r asking for 4 different options,if it is fixed then create an two dimensional array of size [5][4].Loop through it and set the value(vendorName,alt1..)

 
Old September 10th, 2004, 09:05 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

Hi,
   If you look at the following code, you can get an idea...
--------------------------------
This is code for the 1st Page(Vendor.asp).
------------------------------
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<form name=fVendor method=post action="save.asp">
<%For i=1 To 5%>
    Author:<input type=text name=tVendor<%=i%>><br>
    &nbsp;&nbsp;&nbsp;alt1:<input type=text name=alt1<%=i%>><br>
    &nbsp;&nbsp;&nbsp;alt2:<input type=text name=alt2<%=i%>><br>
    &nbsp;&nbsp;&nbsp;alt3:<input type=text name=alt3<%=i%>><br><br>
<%Next%>
<input type=submit value=clickMe>
</form>

<P>&nbsp;</P>

</BODY>
</HTML>


-----------------------------------
This is the code for the 2nd page(save.asp)
----------------------------------

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
For i=1 to 5
    str1 = "tVendor" & i
    alt1 = "alt1" & i
    alt2 = "alt2" & i
    alt3 = "alt3" & i
    Response.Write Request.Form(str1) & "<br>"
    Response.Write Request.Form(alt1) & "<br>"
    Response.Write Request.Form(alt2) & "<br>"
    Response.Write Request.Form(alt3) & "<br>"
Next
%>

<P>&nbsp;</P>

</BODY>
</HTML>
--------------------------------------------




 
Old September 10th, 2004, 09:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Terry,

Can you explain a bit about how it looks on your form and how you want that to be stored. I feel the sureshbabu's suggested code is not what Terry is looking for.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
passing Multidimensional Array Values back to form stitch Classic ASP Databases 2 June 21st, 2013 01:59 PM
Capturing Dynamically Added Client Values Colonel Angus ASP.NET 1.0 and 1.1 Professional 4 April 14th, 2006 12:38 PM
Store Array of Form Values lbunnell Beginning PHP 1 June 21st, 2005 10:13 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
capturing form closed events alexferrie C# 2 June 17th, 2003 10:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.