...

View Full Version : Email Form ASP - Want to Sort Results



Meers
12-05-2003, 05:06 PM
Hi,

on my form
http://darkstonekennel.com/webapplication.html

I have many results to be sent via the form

The results come back not in the order that they are listed on the application.

I would like them to come back as listed on the form.

Can anyone tell me how to do this?

Thanks

Laura

Meers
12-05-2003, 05:13 PM
Oh and I'm COMPLETELY GREEN when it comes to asp code.

Sorry... I'm trying to learn... but its not going well.

Heres my sendmail.asp code

<%
For Each x In Request.Form
message=message & x & ": " & Request.Form(x) & CHR(10)
Next

set smtp = Server.CreateObject("Bamboo.SMTP")
' You only need to change the smtp.Rcpt ans smpt.from part to your email address
smtp.Server = "mail.darkstonekennel.com"
smtp.Rcpt = "laura@crestwoodscorsos.com"
smtp.From = Request.form("email")
smtp.FromName = Request.form("Name")
smtp.Subject = "WebApplication"
smtp.Message = message
on error resume next
smtp.Send
if err then
response.Write err.Description
else
response.Write ("Thank you for your submission.... Your message has been delivered successfully.")
end if
set smtp = Nothing
%>

Would love for someone to show me exactly what to change, where to change it

Spudhead
12-05-2003, 06:13 PM
Well... there's two ways.

One is to get all your form fields out by name - obviously this isn't going to be ideal if you've got thousands of fields, or if they change frequently, but it will allow you to build up the email content exactly as you wish:

message=message &"FieldName1: " & Request.Form("FieldName1") & CHR(10)
message=message &"FieldName2: " & Request.Form("FieldName2") & CHR(10)

etc etc...

The other is.. I'm not sure. Your form fields are coming through in a funny order because - I think - (a) there's no inherent ordering in a GET or POST and... it just comes through as it is... and (b) the fields are laid out in the HTML form in such a way as to make it think that IS the correct order. You could try reorganising the form layout so that the HTML form elements more closely resemble the ordering you're after; I'm not sure if giving the form elements a "tabindex" attribute might help - it's certainly the only attribute I can think of that would influence the ordering.

Sorry if that was a load of useless waffle.

Meers
12-05-2003, 07:16 PM
hi

thanks for the help

I'm assuming that

message=message &"FieldName1: " & Request.Form("FieldName1") & CHR(10)
message=message &"FieldName2: " & Request.Form("FieldName2") & CHR(10)


goes toward the top where it says

<%
For Each x In Request.Form
message=message & x & ": " & Request.Form(x) & CHR(10)
Next

and I replace the message=message.... with your suggestions?

and do I replace each "FieldName1: " & ("FieldName1") with my item names? And do they need parenthesis around them and the " " ??

thanks

Meers
12-05-2003, 07:30 PM
I"VE FIGURED IT OUT!!! YIPPIE!!!

Thanks so much for your help!

Laura

Meers
12-05-2003, 07:49 PM
Ok - it sorts it in my order

but it repeats all of the entries MANY MANY times (in order) but over and over.

how to END after last field???

Roy Sinclair
12-05-2003, 09:38 PM
Show your current code, when it comes to a problem in code we can't help with what we cannot see.

Meers
12-05-2003, 09:41 PM
<%
For Each x In Request.Form
message=message &"Breed: " & Request.Form("Breed") & CHR(10)
message=message &"Name: " & Request.Form("Name") & CHR(10)
message=message &"email: " & Request.Form("email") & CHR(10)
message=message &"Address: " & Request.Form("Address") & CHR(10)
message=message &"City: " & Request.Form("City") & CHR(10)
message=message &"State/Province: " & Request.Form("State/Province") & CHR(10)
message=message &"Zip: " & Request.Form("Zip") & CHR(10)
message=message &"Day #: " & Request.Form("Day #") & CHR(10)
message=message &"Eve #: " & Request.Form("Eve #") & CHR(10)
message=message &"Cell #: " & Request.Form("Cell #") & CHR(10)
message=message &"Best time to call: " & Request.Form("Best time to call") & CHR(10)
message=message &"Adults: " & Request.Form("Adults") & CHR(10)
message=message &"Children: " & Request.Form("Children") & CHR(10)
message=message &"Other Pets: " & Request.Form("Other pets?") & CHR(10)
message=message &"Other Pet Description: " & Request.Form("Other Pet Description") & CHR(10)
message=message &"Vet's Name: " & Request.Form("Vet's Name") & CHR(10)
message=message &"Vet's Address & Phone #: " & Request.Form("Vet's Address & Phone #") & CHR(10)
message=message &"Own/Rent: " & Request.Form("Own/Rent") & CHR(10)
message=message &"Residence Type: " & Request.Form("Residence Type") & CHR(10)
message=message &"How long at residence: " & Request.Form("How Long at residence") & CHR(10)
message=message &"Any plans to move: " & Request.Form("Any plans to move") & CHR(10)
message=message &"Yard: " & Request.Form("Yard") & CHR(10)
message=message &"Yard Description: " & Request.Form("Yard Description") & CHR(10)
message=message &"Inside/Outside: " & Request.Form("Inside/Outside") & CHR(10)
message=message &"Describe Shelter: " & Request.Form("Describe Shelter") & CHR(10)
message=message &"Home during day: " & Request.Form("Home during day") & CHR(10)
message=message &"Hours per day: " & Request.Form("Hours per day") & CHR(10)
message=message &"Owned a dog?: " & Request.Form("Owned a dog?") & CHR(10)
message=message &"Other Dog Description: " & Request.Form("Other dog description") & CHR(10)
message=message &"Why a CC/Rottie: " & Request.Form("Why a CC / Rottie") & CHR(10)
message=message &"Canine Experience: " & Request.Form("Canine experience") & CHR(10)
message=message &"Trainer?: " & Request.Form("Trainer?") & CHR(10)
message=message &"Activities: " & Request.Form("Activities") & CHR(10)
message=message &"Timeframe: " & Request.Form("Timeframe") & CHR(10)
message=message &"Purpose: " & Request.Form("Purpose") & CHR(10)
message=message &"Male or female: " & Request.Form("Male or female") & CHR(10)
message=message &"spay/neuter: " & Request.Form("spay/neuter") & CHR(10)
message=message &"Color: " & Request.Form("Color") & CHR(10)
message=message &"ears: " & Request.Form("ears") & CHR(10)
message=message &"References: " & Request.Form("References") & CHR(10)
message=message &"Additional Info: " & Request.Form("Add'l info") & CHR(10)
message=message &"Signature: " & Request.Form("Signature") & CHR(10)
Next

set smtp = Server.CreateObject("Bamboo.SMTP")
' You only need to change the smtp.Rcpt ans smpt.from part to your email address
smtp.Server = "mail.darkstonekennel.com"
smtp.Rcpt = "laura@crestwoodscorsos.com"
smtp.From = "laura@crestwoodscorsos.com"
smtp.FromName = Request.form("email")
smtp.Subject = "Puppy Application"
smtp.Message = message
on error resume next
smtp.Send
if err then
response.Write err.Description
else
response.Write ("Thank you for your submission.... Your message has been delivered successfully.")
end if
set smtp = Nothing
%>

Roy Sinclair
12-05-2003, 09:57 PM
Drop these two lines:

For Each x In Request.Form
...
Next


They cause all of the code between them to be executed once for each field in your form.

Spudhead
12-08-2003, 12:03 PM
LOL :D Yeah sorry - should have mentioned removing the loop :)

Meers
12-08-2003, 02:29 PM
No problem!

Thank you all for your help!

Totally new code to me - feel sort of enlightened to have learned a bit about it now!

Thanks again

Laura



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum