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

P

Pat Patterson

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
%>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top