Multi page form

This is a discussion on "Multi page form" within the Classic ASP section. This forum, and the thread "Multi page form are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 15th, 2003, 23:33
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Multi page form

Hi

Well I have a major problem and I was informed that this is a good forum for help with asp. This is my problem. I have a form that has about 50 questions and I need to split it into 3 pages. When everything is filled out I would like to send all the info with CDOSYS or CDO not CDONTS. I have had no problems getting all this to work with this script below except that all the info is not sorted.

When I only have one question per page it works fine, when I add about 15 questions on each page and then send it all the questions appear in the email body but not in order. They appear randomly and I can't figure out how I should sort this... Any ideas. I really need this to work..

Here is the code...

<%
Sub SendHiddenFormFields ()
For Each Field In Request.Form
TheString = "<input type=""hidden"" " _
& "name=""" & Field & """ value="""
Value = Request.Form(Field)
TheString = TheString + CStr(Value) & """>" & vbCrLf
Response.Write TheString
Next
End Sub

Sub ReadFormVariables()
For Each Field In Request.Form
TheString = Field & " = Request.Form(""" & Field & """)"
Execute(TheString)
Next
End Sub
%>


<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->


<FORM METHOD="post">
<%
Dim sNextStep
sNextStep = request.form("current")
If sNextStep = "" Then
sNextStep = 1
Else
sNextStep = CINT(sNextStep) + 1
End If

for each i in Request.Form
if left(i,1)="s" then
Response.write("<INPUT TYPE=hidden NAME='" & i & "' VALUE='" & Request.Form(i) & "'>")
end if
next

Response.write("<INPUT TYPE=""hidden"" NAME=""current"" VALUE=""" & sNextStep & """>")

' Output form for next step
select case sNextStep
case "1": ' step 1
%>
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=#EEEEEE ALIGN=CENTER>
<TR><TD>Name</TD><TD><INPUT TYPE="text" NAME="s1_Name"></TD></TR>
<TR><TD>Age</TD><TD><INPUT TYPE="text" NAME="s1_Age"></TD></TR>
<TR><TD>Address</TD><TD><INPUT TYPE="text" NAME="s1_Address"></TD></TR>
<TR><TD>Country</TD><TD><INPUT TYPE="text" NAME="s1_Country"></TD></TR>
<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=submit VALUE="Next...">
</TABLE>
<% case "2": ' Step 2 %>
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=#EEEEEE ALIGN=CENTER>
<TR><TD>Name</TD><TD><INPUT TYPE="text" NAME="s1_Name2"></TD></TR>
<TR><TD>Age</TD><TD><INPUT TYPE="text" NAME="s1_Age2"></TD></TR>
<TR><TD>Address</TD><TD><INPUT TYPE="text" NAME="s1_Address2"></TD></TR>
<TR><TD>Country</TD><TD><INPUT TYPE="text" NAME="s1_Country2"></TD></TR>
<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=submit VALUE="Next...">
</TABLE>
<% case "3": ' Step 3 %>
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=#EEEEEE ALIGN=CENTER>
<TR><TD>Name</TD><TD><INPUT TYPE="text" NAME="s1_Name3"></TD></TR>
<TR><TD>Age</TD><TD><INPUT TYPE="text" NAME="s1_Age3"></TD></TR>
<TR><TD>Address</TD><TD><INPUT TYPE="text" NAME="s1_Address3"></TD></TR>
<TR><TD>Country</TD><TD><INPUT TYPE="text" NAME="s1_Country3"></TD></TR>
</TD></TR>

<TR><TD ALIGN=CENTER COLSPAN=2><INPUT TYPE=submit VALUE="Next..."></TD></TR>
</TABLE>
<% case "4": ' Step 4%

body = ""
for each i in Request.Form
if left(i,1)="s" then
body = body & Mid(i,2) & ": " & Request.Form(i) & vbNewLine
End If
Next

set objMessage = CreateObject("CDO.Message")
objMessage.To = "mail@mail.se"
objMessage.From = "mail@mail.se"
objMessage.Subject = "Test CDO Message"
objMessage.Sender = "mail@mail.se"
objMessage.Textbody = body + vbNewLine


set objConfig = CreateObject("CDO.Configuration")
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer) = "192.168.100.20"
objConfig.Fields(cdoSMTPServerPort) = 25
objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous
objConfig.Fields.Update
set objMessage.Configuration = objConfig



objMessage.Send

set objConfig = Nothing
set objMessage = Nothing
End Select
%>
</FORM>

  #2 (permalink)  
Old Sep 16th, 2003, 05:57
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Instead of using a FOR EACH in building the email body make an array of the field names in the order you want them, then do a FOR loop through the array building the email body with that.

Lemme know if you need more details on how to do that, but that's the general concept.
  #3 (permalink)  
Old Sep 16th, 2003, 22:01
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I'm sorry to say that I do need some more details on what you just said.
  #4 (permalink)  
Old Sep 17th, 2003, 05:23
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
No problem. Replace this line

<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">for each i in Request.Form<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

With

Code: Select all
ary = split("s1_Name,s1_Age,s1_Name2,s1_Age2,s1_Address2")
for a = 0 to ubound(ary,1)
	i = request.form(ary(a))
I only put 5 of the field names in for an example, so replace that with the list of all the field names in the order you want them to come out in the email (separate with a comma, no spaces).
  #5 (permalink)  
Old Sep 17th, 2003, 21:48
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Ahhh thanks that worked great. Was bit of a job as I had 55 fields. But it was worth it as I could now place the fields where I wanted them.

Cheers
Closed Thread

Tags
multi, page, form

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-league and Multi-tiered team schedule overkil6 Website Planning 3 Jun 17th, 2008 22:04
Form Submission page markusdavid Web Page Design 3 Sep 8th, 2007 00:50
Help creating a Multi line order form wacara Classic ASP 0 Apr 23rd, 2007 18:25
Form action same as form page? Tim356 PHP Forum 2 Jun 20th, 2005 03:32
Submitting a form on one page! courtjester Classic ASP 5 Sep 10th, 2004 19:03


All times are GMT. The time now is 20:56.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43