Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP: Multiple page forms, with dynamic form elements - HELP!

Reply
Thread Tools

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

 
 
Pat Patterson
Guest
Posts: n/a
 
      10-21-2005
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
%>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newb: recurse over elements children and disable all form elements SteveKlett@gmail.com Javascript 4 09-20-2006 07:42 AM
To allow left click only on some elements of web page NOT all elements vikas.khengare@gmail.com Javascript 1 05-31-2006 09:26 AM
Revised: A form -to- dynamic form -to- dynamic checkboxes pizzy Javascript 7 03-23-2005 10:53 PM
Dynamic Form with a Dynamic Form inside it... pizzy Javascript 4 03-18-2005 05:10 AM
Generating dynamic form elements "<asp:button ..." Venus ASP .Net 7 08-18-2004 03:32 PM



Advertisments