473,287 Members | 1,868 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,287 software developers and data experts.

Request.Form to retrieve looped form fields

Hi,

I have some code in my form as follows, to display 1 to 20 additional
sets of fields to enter guest information.
I am not sure how to retrieve these guests info so that I can post the
info on an email such as:

Additional Guest 1
First Name =
Last Name =

Additional Guest 2
First Name =
Last Name =

i.e. The 'First Name' for guest 1 is name="AG_fn<%=x%>"
The code loops through depending how many sets of fields were
completed.

-----------------------------------------------------------------------------------------------------------------------------

<!-- begin ASP loop, creating 20 additional group members -->
<% for x=1 to 20 %>
<fieldset id="ag_<%=x%>">
<legend>Additional Group Member <%=x%></legend>
<span id="ag_remove_<%=x%>" style="float: right; padding-right:
8px"><a href="javascript:remove_person(<%=x%>)">remove this person</
a></span>
<p><label for="AG_fn<%=x%>">First name:</label>
<input class="inp" name="AG_fn<%=x%>" id="AG_fn<%=x%>"
type="text" /></p>

<p><label for="AG_ln<%=x%>">Last name:</label>
<input class="inp" name="AG_ln<%=x%>" id="AG_ln<%=x%>"
type="text" /></p>

<p><label for="AG_rt<%=x%>">Room Type:</label>
<select name="AG_rt<%=x%>" id="AG_rt<%=x%>">
<option value="Single">Single</option>
<option value="Double">Double</option>
<option value="Twin">Twin</option>
</select></p>

<p><label for="AG_i<%=x%>">Insurance?</label>
<select name="AG_i<%=x%>" id="AG_i<%=x%>">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<span class="instruction">Do you require travel insurance?</span></
p>

<p><label for="AG_age<%=x%>">Age:</label>
<input class="inp small" name="AG_age<%=x%>" id="AG_age<%=x
%>" type="text" />
<span class="instruction">(if under 18)</span></p>
</fieldset>
<% next %>
<!-- end loop -->
--------------------------------------------------------------------------------

How would I retrieve each additional guests info and store it into
variables ? Thanks

David

Sep 20 '07 #1
3 2617
"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
Hi,

I have some code in my form as follows, to display 1 to 20 additional
sets of fields to enter guest information.
I am not sure how to retrieve these guests info so that I can post the
info on an email such as:

Additional Guest 1
First Name =
Last Name =

Additional Guest 2
First Name =
Last Name =

i.e. The 'First Name' for guest 1 is name="AG_fn<%=x%>"
The code loops through depending how many sets of fields were
completed.

--------------------------------------------------------------------------
---------------------------------------------------
>
<!-- begin ASP loop, creating 20 additional group members -->
<% for x=1 to 20 %>
<fieldset id="ag_<%=x%>">
<legend>Additional Group Member <%=x%></legend>
<span id="ag_remove_<%=x%>" style="float: right; padding-right:
8px"><a href="javascript:remove_person(<%=x%>)">remove this person</
a></span>
<p><label for="AG_fn<%=x%>">First name:</label>
<input class="inp" name="AG_fn<%=x%>" id="AG_fn<%=x%>"
type="text" /></p>

<p><label for="AG_ln<%=x%>">Last name:</label>
<input class="inp" name="AG_ln<%=x%>" id="AG_ln<%=x%>"
type="text" /></p>

<p><label for="AG_rt<%=x%>">Room Type:</label>
<select name="AG_rt<%=x%>" id="AG_rt<%=x%>">
<option value="Single">Single</option>
<option value="Double">Double</option>
<option value="Twin">Twin</option>
</select></p>

<p><label for="AG_i<%=x%>">Insurance?</label>
<select name="AG_i<%=x%>" id="AG_i<%=x%>">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<span class="instruction">Do you require travel insurance?</span></
p>

<p><label for="AG_age<%=x%>">Age:</label>
<input class="inp small" name="AG_age<%=x%>" id="AG_age<%=x
%>" type="text" />
<span class="instruction">(if under 18)</span></p>
</fieldset>
<% next %>
<!-- end loop -->
--------------------------------------------------------------------------
------
>
How would I retrieve each additional guests info and store it into
variables ? Thanks

David
Are you looking for something like this?

<%
Const cAG = 20
Dim arrAG(cAG)
Dim intAG

For intAG = 1 to cAG
arrAG(intAG) = Request.Form("AG_fn" & intAG)
arrAG(intAG) = Request.Form("AG_ln" & intAG)
arrAG(intAG) = Request.Form("AG_rt" & intAG)
arrAG(intAG) = Request.Form("AG_i" & intAG)
arrAG(intAG) = Request.Form("AG_age" & intAG)
Next
%>
Sep 20 '07 #2
On 20 Sep, 13:19, "McKirahan" <N...@McKirahan.comwrote:
"David" <davidgor...@scene-double.co.ukwrote in message

news:11**********************@r29g2000hsg.googlegr oups.com...


Hi,
I have some code in my form as follows, to display 1 to 20 additional
sets of fields to enter guest information.
I am not sure how to retrieve these guests info so that I can post the
info on an email such as:
Additional Guest 1
First Name =
Last Name =
Additional Guest 2
First Name =
Last Name =
i.e. The 'First Name' for guest 1 is name="AG_fn<%=x%>"
The code loops through depending how many sets of fields were
completed.
--------------------------------------------------------------------------

---------------------------------------------------


<!-- begin ASP loop, creating 20 additional group members -->
<% for x=1 to 20 %>
<fieldset id="ag_<%=x%>">
<legend>Additional Group Member <%=x%></legend>
<span id="ag_remove_<%=x%>" style="float: right; padding-right:
8px"><a href="javascript:remove_person(<%=x%>)">remove this person</
a></span>
<p><label for="AG_fn<%=x%>">First name:</label>
<input class="inp" name="AG_fn<%=x%>" id="AG_fn<%=x%>"
type="text" /></p>
<p><label for="AG_ln<%=x%>">Last name:</label>
<input class="inp" name="AG_ln<%=x%>" id="AG_ln<%=x%>"
type="text" /></p>
<p><label for="AG_rt<%=x%>">Room Type:</label>
<select name="AG_rt<%=x%>" id="AG_rt<%=x%>">
<option value="Single">Single</option>
<option value="Double">Double</option>
<option value="Twin">Twin</option>
</select></p>
<p><label for="AG_i<%=x%>">Insurance?</label>
<select name="AG_i<%=x%>" id="AG_i<%=x%>">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
<span class="instruction">Do you require travel insurance?</span></
p>
<p><label for="AG_age<%=x%>">Age:</label>
<input class="inp small" name="AG_age<%=x%>" id="AG_age<%=x
%>" type="text" />
<span class="instruction">(if under 18)</span></p>
</fieldset>
<% next %>
<!-- end loop -->
--------------------------------------------------------------------------
------
How would I retrieve each additional guests info and store it into
variables ? Thanks
David

Are you looking for something like this?
Thanks,

I get this error though !

Microsoft VBScript compilation error '800a0402'

Expected integer constant

/Form_Ski/Booking_thanks.asp, line 61

Dim arrAG(cAG)
----------^
------------------------------------------------------------------------------------------------------------------------

<%
Const cAG = 20
Dim arrAG(cAG)
Dim intAG

For intAG = 1 to cAG
arrAG(intAG) = Request.Form("AG_fn" & intAG)
arrAG(intAG) = Request.Form("AG_ln" & intAG)
arrAG(intAG) = Request.Form("AG_rt" & intAG)
arrAG(intAG) = Request.Form("AG_i" & intAG)
arrAG(intAG) = Request.Form("AG_age" & intAG)
Next
%>

Sep 20 '07 #3
David wrote:
Expected integer constant

/Form_Ski/Booking_thanks.asp, line 61

Dim arrAG(cAG)
----------^
A variable cannot be used here. In vbscript one must first declare a dynamic
array (note the empty parentheses):

Dim arrAG()

.... and then redim it:

ReDim arrAG(cAG)
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Sep 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tim Chmielewski | last post by:
For an auto-generated form I have the following order of fields: savevalues userid productcode PrintColour1_1 Colour1_1 Quantity_1 " " " " " " " ...
6
by: Agoston Bejo | last post by:
Hi. x1.asp: <form method="post" action="x2.asp"> .... </form> x2.asp: DoSomeAdministration() Response.Redirect "x3.asp?" & Request.Form x3.asp: further processsing of data
6
by: Drew | last post by:
I have been trying to figure out why I am getting this message... I have an application that is 20 different ASP pages that works in sequential order (step1, step2, step3...). After each step the...
8
by: George | last post by:
VS.NET 2002/VB Is it possible to retrieve HTML form variables that are hidden input types using Request.QueryString() and/or Request.Form()? I have tried various ways of using those, but to no...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.