Request.Form to retrieve looped form fields

Discussion in 'ASP General' started by David, Sep 20, 2007.

  1. David

    David Guest

    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
     
    David, Sep 20, 2007
    #1
    1. Advertising

  2. David

    David Guest

    On 20 Sep, 13:19, "McKirahan" <> wrote:
    > "David" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > 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
    > %>
     
    David, Sep 20, 2007
    #2
    1. Advertising

  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"
     
    Bob Barrows [MVP], Sep 20, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alec maclean

    Looped output of images via MemoryStream?

    alec maclean, Apr 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    348
    alec maclean
    Apr 20, 2004
  2. lotmr

    looped if's stop working

    lotmr, Mar 28, 2005, in forum: Python
    Replies:
    0
    Views:
    293
    lotmr
    Mar 28, 2005
  3. Dragilla

    looped include

    Dragilla, Oct 7, 2007, in forum: C++
    Replies:
    5
    Views:
    310
    Dragilla
    Oct 7, 2007
  4. Replies:
    18
    Views:
    337
    Dooza
    Jul 25, 2008
  5. Brian A
    Replies:
    1
    Views:
    113
    Brian A
    Oct 15, 2007
Loading...

Share This Page