dude9er
15 Jan 2006, 01:18 AM
I've modified this multi page form for a website I'm designing and am having problems with validating the form for each page. I'd also like to write the data to an access_db file called kimber_sweeps.mdb .
Can someone who is an ASP genius please help as I have a deadline for this Monday.
Thanks for any help in advance.
here is the form online.
http://www.affinity-nra-travel.com/kimber/kimbergiveawayTEST.asp
<%
Const NUMBER_OF_PAGES = 3
Dim intPreviousPage
Dim intCurrentPage
Dim strItem
' What page did we come from?
intPreviousPage = Request.Form("page")
' What page are we on?
Select Case Request.Form("navigate")
Case "< Back"
intCurrentPage = intPreviousPage - 1
Case "Continue >"
intCurrentPage = intPreviousPage + 1
Case Else
' Either it's our first run of the page and we're on page 1 or
' the form is complete and pages are unimportant because we're
' about to process our data!
intCurrentPage = 1
End Select
' If we're not finished then display the form.
If Request.Form("navigate") <> "Submit Entry" Then %>
<form action="<%= Request.ServerVariables("URL") %>" method="post">
<input type="hidden" name="page" value="<%= intCurrentPage %>">
<%
' Take data and store it in hidden form fields. All our fields are
' prefixed with numbers so that we know what page it belongs to.
For Each strItem In Request.Form
' Ignore the "page" and "navigate" button form fields.
If strItem <> "page" And strItem <> "navigate" Then
' If the data is from the current page we don't need
' the hidden field since the data will show in the visible
' form fields.
If CInt(Left(strItem, 1)) <> intCurrentPage Then
Response.Write("<input type=""hidden"" name=""" & strItem & """" _
& " value=""" & Request.Form(strItem) & """>" & vbCrLf)
End If
End If
Next
' Display current page fields. The fields are all named with
' numerical prefix that tells us which page they belong to.
' We need a Case for each page.
Select Case intCurrentPage
Case 1
%>
<table>
<tr>
<td width="144" align="right" class="style2"><strong>First Name:</strong></td>
<td width="372">
<input name="1_name" type="text" value="<%= Request.Form("1_name") %>" size="50"></td>
</tr>
<tr>
<td width="144" align="right" class="style2"><strong>Last Name:</strong></td>
<td width="372"><input name="1_name2" type="text" id="1_name2" value="<%= Request.Form("1_name2") %>" size="50"></td>
</tr>
<tr>
<td width="144" align="right" class="style2"><strong>Phone Number:</strong></td>
<td width="372"><input name="1_phone" type="text" value="<%= Request.Form("1_phone") %>" size="50"></td>
</tr>
<tr>
<td align="right" class="style2"><strong>Email:</strong></td>
<td><input name="1_email" type="text" value="<%= Request.Form("1_email") %>" size="50"></td>
</tr>
<tr>
<td align="right" class="style2"><strong>Gender:</strong></td>
<td><input type="radio" name="1_sex" value="male" <% If Request.Form("1_sex") = "male" Then Response.Write("checked=""checked""") %>>Male
<input type="radio" name="1_sex" value="female" <% If Request.Form("1_sex") = "female" Then Response.Write("checked=""checked""") %>>Female</td>
</tr>
<tr>
<td align="right"><span class="style2"><strong>Age</strong></span><strong>:</strong></td>
<td><select name="1_age">
<option>18 - 29</option>
<option<% If Request.Form("1_age") = "30 - 39" Then Response.Write(" selected=""selected""") %>>30 - 39</option>
<option<% If Request.Form("1_age") = "40 - 49" Then Response.Write(" selected=""selected""") %>>40 - 49</option>
<option<% If Request.Form("1_age") = "50 - 59" Then Response.Write(" selected=""selected""") %>>50 - 59</option>
<option<% If Request.Form("1_age") = "60 - 69" Then Response.Write(" selected=""selected""") %>>60 - 69</option>
<option<% If Request.Form("1_age") = "70 - 79" Then Response.Write(" selected=""selected""") %>>70 - 79</option>
<option<% If Request.Form("1_age") = "80 +" Then Response.Write(" selected=""selected""") %>>80 +</option>
</select></td>
</tr>
</table>
<%
Case 2
%>
<table>
<tr>
<td width="57" class="style2"><strong>TERMS</strong></td>
<td width="324"><input name="2_terms" type="checkbox" id="2_terms" value="Checked" <% If Request.Form("2_terms") = "terms" Then Response.Write("checked=""checked""") %>>
<label for="checkbox"></label></td>
</tr><tr></tr>
</table>
<%
Case 3
' Notice that you can do other types of form fields too.
%>
<table>
<tr>
<td width="32" align="right"><input name="3_specials" type="checkbox" id="3_specials" value="Checked" <% If Request.Form("3_specials") = "terms" Then Response.Write("checked=""checked""") %> /></td>
<td width="654" class="style2"><strong>Please notify me via email of any future specials NRA Travel may offer.</strong></td>
</tr><tr>
<td height="54"> </td>
<td height="54" valign="bottom" class="style2">I am particularly interested in the following: </td>
</tr>
<tr>
<td height="89"> </td>
<td height="89" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="style2">
<tr>
<td width="31%"><input name="4_alaska" type="checkbox" id="4_alaska" value="Alaskan Cruise" <% If Request.Form("4_alaska") = "checked" Then Response.Write("checked=""checked""") %> />
Alaskan Cruises </td>
<td width="36%"><input name="4_europe" type="checkbox" id="4_europe" value="Europe" <% If Request.Form("4_europe") = "checked" Then Response.Write("checked=""checked""") %> />
Europe</td>
<td width="29%"><input name="4_allinclusive" type="checkbox" id="4_allinclusive" value="All Inclusive" <% If Request.Form("4_allinclusive") = "checked" Then Response.Write("checked=""checked""") %> />
All Inclusives </td>
<td width="4%"> </td>
</tr>
<tr>
<td><input name="4_Hawaii" type="checkbox" id="4_Hawaii" value="Hawaii" <% If Request.Form("4_Hawaii") = "checked" Then Response.Write("checked=""checked""") %> />
Hawaii</td>
<td><input name="4_CaribbeanCruise" type="checkbox" id="4_CaribbeanCruise" value="Caribbean Cruise" <% If Request.Form("4_CaribbeanCruise") = "checked" Then Response.Write("checked=""checked""") %> />
Caribbean Cruises</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><input name="4_mexico" type="checkbox" id="4_mexico" value="Mexico" <% If Request.Form("3_specials") = "checked" Then Response.Write("checked=""checked""") %> />
Mexico</td>
<td><input name="4_mexicoCruise" type="checkbox" id="4_mexicoCruise" value="Mexico Cruise" <% If Request.Form("4_mexicoCruise") = "checked" Then Response.Write("checked=""checked""") %> />
Mexico Cruises </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<%
Case Else
' You shouldn't see this error unless something goes wrong.
Response.Write("Error: Bad Page Number!")
End Select
%>
<br />
<!-- Display form navigation buttons. -->
<% If intCurrentPage > 1 Then %>
<input type="submit" name="navigate" value="< Back">
<% End If %>
<% If intCurrentPage < NUMBER_OF_PAGES Then %>
<input type="submit" name="navigate" value="Continue >">
<% Else %>
<input type="submit" name="navigate" value="Submit Entry">
<% End If %>
</form>
<%
Else
' This is where we process our data when the user submits the final page.
' I just display the data, but you're free to store the data in a
' database, send it via email, or do whatever you want with it.
'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>First Name:</strong> <%= Request.Form("1_name") %>
<strong>Last Name:</strong> <%= Request.Form("1_name2") %>
<strong>Phone Number:</strong> <%= Request.Form("1_phone") %>
<strong>Email:</strong> <%= Request.Form("1_email") %>
<strong>Sex:</strong> <%= Request.Form("1_sex") %>
<strong>Age:</strong> <%= Request.Form("1_age") %>
<strong>Term & Conditions:</strong><%= Request.Form("2_terms") %>
<strong>Special Offers:</strong><%= Request.Form("3_specials") %>
<strong>Selected Offer:</strong><%= Request.Form("4_alaska") %>
<strong>Selected Offer:</strong><%= Request.Form("4_Hawaii") %>
<strong>Selected Offer:</strong><%= Request.Form("4_mexico") %>
<strong>Selected Offer:</strong><%= Request.Form("4_CaribbeanCruise") %>
<strong>Selected Offer:</strong><%= Request.Form("4_mexicoCruise") %>
<strong>Selected Offer:</strong><%= Request.Form("4_allinclusive") %>
</pre>
<p>
<a href="<%= Request.ServerVariables("URL") %>">Start Again</a>
</p>
<%
End If
%>
Can someone who is an ASP genius please help as I have a deadline for this Monday.
Thanks for any help in advance.
here is the form online.
http://www.affinity-nra-travel.com/kimber/kimbergiveawayTEST.asp
<%
Const NUMBER_OF_PAGES = 3
Dim intPreviousPage
Dim intCurrentPage
Dim strItem
' What page did we come from?
intPreviousPage = Request.Form("page")
' What page are we on?
Select Case Request.Form("navigate")
Case "< Back"
intCurrentPage = intPreviousPage - 1
Case "Continue >"
intCurrentPage = intPreviousPage + 1
Case Else
' Either it's our first run of the page and we're on page 1 or
' the form is complete and pages are unimportant because we're
' about to process our data!
intCurrentPage = 1
End Select
' If we're not finished then display the form.
If Request.Form("navigate") <> "Submit Entry" Then %>
<form action="<%= Request.ServerVariables("URL") %>" method="post">
<input type="hidden" name="page" value="<%= intCurrentPage %>">
<%
' Take data and store it in hidden form fields. All our fields are
' prefixed with numbers so that we know what page it belongs to.
For Each strItem In Request.Form
' Ignore the "page" and "navigate" button form fields.
If strItem <> "page" And strItem <> "navigate" Then
' If the data is from the current page we don't need
' the hidden field since the data will show in the visible
' form fields.
If CInt(Left(strItem, 1)) <> intCurrentPage Then
Response.Write("<input type=""hidden"" name=""" & strItem & """" _
& " value=""" & Request.Form(strItem) & """>" & vbCrLf)
End If
End If
Next
' Display current page fields. The fields are all named with
' numerical prefix that tells us which page they belong to.
' We need a Case for each page.
Select Case intCurrentPage
Case 1
%>
<table>
<tr>
<td width="144" align="right" class="style2"><strong>First Name:</strong></td>
<td width="372">
<input name="1_name" type="text" value="<%= Request.Form("1_name") %>" size="50"></td>
</tr>
<tr>
<td width="144" align="right" class="style2"><strong>Last Name:</strong></td>
<td width="372"><input name="1_name2" type="text" id="1_name2" value="<%= Request.Form("1_name2") %>" size="50"></td>
</tr>
<tr>
<td width="144" align="right" class="style2"><strong>Phone Number:</strong></td>
<td width="372"><input name="1_phone" type="text" value="<%= Request.Form("1_phone") %>" size="50"></td>
</tr>
<tr>
<td align="right" class="style2"><strong>Email:</strong></td>
<td><input name="1_email" type="text" value="<%= Request.Form("1_email") %>" size="50"></td>
</tr>
<tr>
<td align="right" class="style2"><strong>Gender:</strong></td>
<td><input type="radio" name="1_sex" value="male" <% If Request.Form("1_sex") = "male" Then Response.Write("checked=""checked""") %>>Male
<input type="radio" name="1_sex" value="female" <% If Request.Form("1_sex") = "female" Then Response.Write("checked=""checked""") %>>Female</td>
</tr>
<tr>
<td align="right"><span class="style2"><strong>Age</strong></span><strong>:</strong></td>
<td><select name="1_age">
<option>18 - 29</option>
<option<% If Request.Form("1_age") = "30 - 39" Then Response.Write(" selected=""selected""") %>>30 - 39</option>
<option<% If Request.Form("1_age") = "40 - 49" Then Response.Write(" selected=""selected""") %>>40 - 49</option>
<option<% If Request.Form("1_age") = "50 - 59" Then Response.Write(" selected=""selected""") %>>50 - 59</option>
<option<% If Request.Form("1_age") = "60 - 69" Then Response.Write(" selected=""selected""") %>>60 - 69</option>
<option<% If Request.Form("1_age") = "70 - 79" Then Response.Write(" selected=""selected""") %>>70 - 79</option>
<option<% If Request.Form("1_age") = "80 +" Then Response.Write(" selected=""selected""") %>>80 +</option>
</select></td>
</tr>
</table>
<%
Case 2
%>
<table>
<tr>
<td width="57" class="style2"><strong>TERMS</strong></td>
<td width="324"><input name="2_terms" type="checkbox" id="2_terms" value="Checked" <% If Request.Form("2_terms") = "terms" Then Response.Write("checked=""checked""") %>>
<label for="checkbox"></label></td>
</tr><tr></tr>
</table>
<%
Case 3
' Notice that you can do other types of form fields too.
%>
<table>
<tr>
<td width="32" align="right"><input name="3_specials" type="checkbox" id="3_specials" value="Checked" <% If Request.Form("3_specials") = "terms" Then Response.Write("checked=""checked""") %> /></td>
<td width="654" class="style2"><strong>Please notify me via email of any future specials NRA Travel may offer.</strong></td>
</tr><tr>
<td height="54"> </td>
<td height="54" valign="bottom" class="style2">I am particularly interested in the following: </td>
</tr>
<tr>
<td height="89"> </td>
<td height="89" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="style2">
<tr>
<td width="31%"><input name="4_alaska" type="checkbox" id="4_alaska" value="Alaskan Cruise" <% If Request.Form("4_alaska") = "checked" Then Response.Write("checked=""checked""") %> />
Alaskan Cruises </td>
<td width="36%"><input name="4_europe" type="checkbox" id="4_europe" value="Europe" <% If Request.Form("4_europe") = "checked" Then Response.Write("checked=""checked""") %> />
Europe</td>
<td width="29%"><input name="4_allinclusive" type="checkbox" id="4_allinclusive" value="All Inclusive" <% If Request.Form("4_allinclusive") = "checked" Then Response.Write("checked=""checked""") %> />
All Inclusives </td>
<td width="4%"> </td>
</tr>
<tr>
<td><input name="4_Hawaii" type="checkbox" id="4_Hawaii" value="Hawaii" <% If Request.Form("4_Hawaii") = "checked" Then Response.Write("checked=""checked""") %> />
Hawaii</td>
<td><input name="4_CaribbeanCruise" type="checkbox" id="4_CaribbeanCruise" value="Caribbean Cruise" <% If Request.Form("4_CaribbeanCruise") = "checked" Then Response.Write("checked=""checked""") %> />
Caribbean Cruises</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><input name="4_mexico" type="checkbox" id="4_mexico" value="Mexico" <% If Request.Form("3_specials") = "checked" Then Response.Write("checked=""checked""") %> />
Mexico</td>
<td><input name="4_mexicoCruise" type="checkbox" id="4_mexicoCruise" value="Mexico Cruise" <% If Request.Form("4_mexicoCruise") = "checked" Then Response.Write("checked=""checked""") %> />
Mexico Cruises </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<%
Case Else
' You shouldn't see this error unless something goes wrong.
Response.Write("Error: Bad Page Number!")
End Select
%>
<br />
<!-- Display form navigation buttons. -->
<% If intCurrentPage > 1 Then %>
<input type="submit" name="navigate" value="< Back">
<% End If %>
<% If intCurrentPage < NUMBER_OF_PAGES Then %>
<input type="submit" name="navigate" value="Continue >">
<% Else %>
<input type="submit" name="navigate" value="Submit Entry">
<% End If %>
</form>
<%
Else
' This is where we process our data when the user submits the final page.
' I just display the data, but you're free to store the data in a
' database, send it via email, or do whatever you want with it.
'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>First Name:</strong> <%= Request.Form("1_name") %>
<strong>Last Name:</strong> <%= Request.Form("1_name2") %>
<strong>Phone Number:</strong> <%= Request.Form("1_phone") %>
<strong>Email:</strong> <%= Request.Form("1_email") %>
<strong>Sex:</strong> <%= Request.Form("1_sex") %>
<strong>Age:</strong> <%= Request.Form("1_age") %>
<strong>Term & Conditions:</strong><%= Request.Form("2_terms") %>
<strong>Special Offers:</strong><%= Request.Form("3_specials") %>
<strong>Selected Offer:</strong><%= Request.Form("4_alaska") %>
<strong>Selected Offer:</strong><%= Request.Form("4_Hawaii") %>
<strong>Selected Offer:</strong><%= Request.Form("4_mexico") %>
<strong>Selected Offer:</strong><%= Request.Form("4_CaribbeanCruise") %>
<strong>Selected Offer:</strong><%= Request.Form("4_mexicoCruise") %>
<strong>Selected Offer:</strong><%= Request.Form("4_allinclusive") %>
</pre>
<p>
<a href="<%= Request.ServerVariables("URL") %>">Start Again</a>
</p>
<%
End If
%>