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
davidgordon [ Do, 20 September 2007 12:54 ] [ ID #1825213 ]

Re: Request.Form to retrieve looped form fields

"David" <davidgordon [at] scene-double.co.uk> wrote in message
news:1190285687.622769.198210 [at] r29g2000hsg.googlegroups.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
%>
McKirahan [ Do, 20 September 2007 14:19 ] [ ID #1825214 ]

Re: Request.Form to retrieve looped form fields

On 20 Sep, 13:19, "McKirahan" <N... [at] McKirahan.com> wrote:
> "David" <davidgor... [at] scene-double.co.uk> wrote in message
>
> news:1190285687.622769.198210 [at] r29g2000hsg.googlegroups.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
> %>
davidgordon [ Do, 20 September 2007 15:20 ] [ ID #1825216 ]

Re: Request.Form to retrieve looped form fields

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"
reb01501 [ Do, 20 September 2007 15:33 ] [ ID #1825217 ]
Webserver » microsoft.public.inetserver.asp.general » Request.Form to retrieve looped form fields

Vorheriges Thema: Loading partial page from file.
Nächstes Thema: PPT viewer in a asp.net web application