468,783 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,783 developers. It's quick & easy.

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 2442
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Drew | last post: by
8 posts views Thread by George | last post: by
9 posts views Thread by eswanson | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.