469,943 Members | 2,352 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

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

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("pkSetting Offered").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
%>

Oct 21 '05 #1
0 1805

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by jedimasta | last post: by
reply views Thread by shamirza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.