ASP: Multiple page forms, with dynamic form elements - HELP!

Discussion in 'ASP General' started by Pat Patterson, Oct 21, 2005.

  1. I'm having serious issues with a page I'm developing. I just need some
    simple help, and was hoping someone might be able to help me out in
    here.

    I have a form, that consists of 3 pages of fields. I'd like to create
    a page in which all of this is stored as you move along as hidden
    variables, until the end, when the user submits. I can't figure out
    one thing: I have dynamic form elements (dropdowns), that I'd like to
    use instead of setting the dropdowns statically.

    Here's the dynamic select I'd like to use - can someone help me out? I
    can't just add them into the code - I keep getting an error message as
    soon as I do it, but I'm not sure why. Novice ASP developer here. :(
    Again, all I want to do is replace the <select> from the ASP page
    underneath with my dynamic <select>...


    <select name="settingOffered" id="settingOffered">
    <%
    While (NOT rssettingOffered.EOF)
    %>
    <option
    value="<%=(rssettingOffered.Fields.Item("pkSettingOffered").Value)%>">
    <%=(rssettingOffered.Fields.Item("settingOffered").Value)%></option>
    <%
    rssettingOffered.MoveNext()
    Wend
    If (rssettingOffered.CursorType > 0) Then
    rssettingOffered.MoveFirst
    Else
    rssettingOffered.Requery
    End If
    %>
    </select>

    **********************************************

    And here's the page that I can't get to work:

    **********************************************

    <%
    Const NUMBER_OF_PAGES = 3

    Dim intPreviousPage
    Dim intCurrentPage
    Dim strItem

    intPreviousPage = Request.Form("page")

    Select Case Request.Form("navigate")
    Case "< Back"
    intCurrentPage = intPreviousPage - 1
    Case "Next >"
    intCurrentPage = intPreviousPage + 1
    Case Else
    intCurrentPage = 1
    End Select

    If Request.Form("navigate") <> "Finish" Then %>
    <form action="<%= Request.ServerVariables("URL") %>" method="post">
    <input type="hidden" name="page" value="<%= intCurrentPage %>">

    <%
    For Each strItem In Request.Form

    If strItem <> "page" And strItem <> "navigate" Then
    If CInt(Left(strItem, 1)) <> intCurrentPage Then
    Response.Write("<input type=""hidden"" name=""" & strItem & """" _
    & " value=""" & Request.Form(strItem) & """>" & vbCrLf)
    End If
    End If
    Next

    Select Case intCurrentPage

    <%
    Case 1
    %>
    <table>
    <tr>
    <td><strong>Age:</strong></td>
    <td>
    <select name="3_age">
    <option></option>
    <option<% If Request.Form("3_age") = "< 20" Then Response.Write("
    selected=""selected""") %>>&lt; 20</option>
    <option<% If Request.Form("3_age") = "20 - 29" Then Response.Write("
    selected=""selected""") %>>20 - 29</option>
    </select>
    </td>
    </tr>
    </table>

    <%
    Case 2
    %>
    <table>
    <tr>
    <td><strong>Age:</strong></td>
    <td>
    <select name="3_age">
    <option></option>
    <option<% If Request.Form("3_age") = "< 20" Then Response.Write("
    selected=""selected""") %>>&lt; 20</option>
    <option<% If Request.Form("3_age") = "20 - 29" Then Response.Write("
    selected=""selected""") %>>20 - 29</option>
    </select>
    </td>
    </tr>
    </table>

    <%
    Case 3
    %>
    <table>
    <tr>
    <td><strong>Age:</strong></td>
    <td>
    <select name="3_age">
    <option></option>
    <option<% If Request.Form("3_age") = "< 20" Then Response.Write("
    selected=""selected""") %>>&lt; 20</option>
    <option<% If Request.Form("3_age") = "20 - 29" Then Response.Write("
    selected=""selected""") %>>20 - 29</option>
    </select>
    </td>
    </tr>
    </table>


    <%
    Case Else
    Response.Write("Error: Bad Page Number!")
    End Select
    %>
    <br />

    <% If intCurrentPage > 1 Then %>
    <input type="submit" name="navigate" value="&lt; Back">
    <% End If %>
    <% If intCurrentPage < NUMBER_OF_PAGES Then %>
    <input type="submit" name="navigate" value="Next &gt;">
    <% Else %>
    <input type="submit" name="navigate" value="Finish">
    <% End If %>
    </form>
    <%
    Else
    For Each strItem In Request.Form
    Response.Write(strItem & ": " & Request.Form(strItem) & "<br />" &
    vbCrLf)
    Next
    %>

    <p><strong>
    Here's what you entered:
    </strong></p>

    <pre>
    <strong>Name:</strong> <%= Request.Form("1_name") %>
    <strong>Email:</strong> <%= Request.Form("1_email") %>
    <strong>Address:</strong> <%= Request.Form("2_address") %>
    <strong>City:</strong> <%= Request.Form("2_city") %>
    <strong>State:</strong> <%= Request.Form("2_state") %>
    <strong>Zip:</strong> <%= Request.Form("2_zip") %>
    <strong>Sex:</strong> <%= Request.Form("3_sex") %>
    <strong>Age:</strong> <%= Request.Form("3_age") %>
    </pre>

    <p>
    <a href="<%= Request.ServerVariables("URL") %>">Start Again</a>
    </p>

    <%
    End If
    %>
     
    Pat Patterson, Oct 21, 2005
    #1
    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. Venus
    Replies:
    7
    Views:
    484
    Justin Beckwith
    Aug 18, 2004
  2. Eric
    Replies:
    2
    Views:
    562
  3. pizzy
    Replies:
    4
    Views:
    145
    pizzy
    Mar 18, 2005
  4. pizzy
    Replies:
    7
    Views:
    162
    pizzy
    Mar 23, 2005
  5. Replies:
    4
    Views:
    147
    Richard Cornford
    Aug 11, 2006
Loading...

Share This Page