473,387 Members | 1,724 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.

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 2621
"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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
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.