Click to See Complete Forum and Search --> : Help required with weird form results


kessa
08-16-2006, 11:27 AM
Hi Guys,

I've got a simple contact form on my website which sends the result using .asp to me via email.

The weird thing is that the order of the information received in the email seems to be random (or at least, doesn't have any correlation to the order of the items in the form itself)

So for example, in my form I have the following items in the following order:

Title
First name
Surname
Address
Town / City
Country
Postcode
Tel
Comments


However, the order in which the result arrive is random (here's an example)

title = Mr
address = address
comments = comments
firstname = name
surname = surname
postcode = postcode
country = country
town = town
tel = daytel


In the words (almost) of Morcambe and Wise... "I've got all the right results, just not necesarily in the right order"

Does anyone have any ideas why this may be happening? I don't think that there is anything too odd about my code but here it is just in case.




html = "<!DOCTYPE html PUBLIC'-//IETF//DTD html//EN'><html><head><meta http-equiv='Content-Type'><content='text/html; charset=iso-8859-1'><title>email</title>"
html = html & "<style type='text/css'><!--"
html = html & ".maintext {font-family: Verdana; font-size: 9pt;color: #333333;font-weight: 400;}"
html = html & ".white-medium {font-family: Verdana; font-size: 11pt;color: #ffffff;font-weight: 400;}"
html = html & "--></style></head><body><span class='maintext'>"
html = html & "<br /><b>Message sent: " & Date & " " & time & "</b><br />"
for each thingy in request.form
if not thingy="Action" then
html = html & "<br />" & thingy & " = " & request(thingy)
end if
next
html = html & "<br /><br />"
html = html & "</span></body></html>"

Set MailObj = Server.CreateObject("CDONTS.NewMail")
MailObj.From = "contactform@mywebsiteaddress.co.uk"
MailObj.To = "email@mywebsiteaddress.co.uk"
MailObj.Subject = "Contact Form"

MailObj.Importance = 1
MailObj.BodyFormat=0
MailObj.MailFormat=0
MailObj.Body = html
MailObj.Send
Set MailObj = Nothing


Thanks
Kessa

russell
08-16-2006, 11:41 AM
no way to know what order the form elements will be in unless u hard-code em

so this
for each thingy in request.form
if not thingy="Action" then
html = html & "<br />" & thingy & " = " & request(thingy)
end if
next
would have to become

html = html & "<br />Title = " & request.form("Title")
html = html & "<br />First name = " & request.form("First name")
html = html & "<br />Surname = " & request.form("Surname")
html = html & "<br />Address = " & request.form("Address")
'' etc

vanny
08-17-2006, 01:38 AM
wont they get submitted through in order they appear on the form

what about

for i = 1 to request.count
html = html & "<br />" & request.form(i).key & " = " & Request.Form(i).Item
next

although this will pick up submit buttons and other items.

russell
08-17-2006, 07:23 AM
wont they get submitted through in order they appear on the form
not necessarily. no way to no what order they'll be in the collection