Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Closed Thread
 
LinkBack Thread Tools
Old September 15th, 2003, 07:33 PM   #1
New Member
 

Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 drnibbles is on a distinguished road
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>
drnibbles is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old September 16th, 2003, 01:57 AM   #2
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118 Webforumz Staff is on a distinguished road
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.
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old September 16th, 2003, 06:01 PM   #3
New Member
 

Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 drnibbles is on a distinguished road
I'm sorry to say that I do need some more details on what you just said.
drnibbles is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old September 17th, 2003, 01:23 AM   #4
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118 Webforumz Staff is on a distinguished road
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:
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).
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old September 17th, 2003, 05:48 PM   #5
New Member
 

Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 drnibbles is on a distinguished road
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
drnibbles is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
multi , page , form


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 How is this done? 3 June 17th, 2008 06:04 PM
Form Submission page markusdavid HTML, XHTML and CSS 3 September 7th, 2007 08:50 PM
Help creating a Multi line order form wacara Classic ASP 0 April 23rd, 2007 02:25 PM
Form action same as form page? Tim356 PHP 2 June 19th, 2005 11:32 PM
Submitting a form on one page! courtjester Classic ASP 5 September 10th, 2004 03:03 PM


Search Engine Optimization by vBSEO 3.2.0 RC8