In order?

P

Paulo Roberto

Hi, I have a html form with a lot of fields in a such order, but when
retrieved by

for each key in request.form
response.write key & " - " & request.form(key) & "<BR>"
next

it lists them all out of order, how could I do a logic to get all of them on
the same order that was put on html?

example if I have:

Name
Address
Age
Birthday
Postal code
etc

the for each doesnt get on the order above... I need to send them via email
and must be on the same html order... can you help me?

Thanks!!!
 
D

daddywhite

retrieve them individually and reassemble in the order desired.

I have done this before but cant access the code right now - think it
is something like below:

for i = 1 to Request.Form.Count
for each name in Request.Form
if Request.Form(name) = Request.Form(i) then
ADD TO EMAIL BODY
end if
Next
Next
 
D

Dave Anderson

Paulo said:
Hi, I have a html form with a lot of fields in a such order, but
when retrieved by

for each key in request.form
response.write key & " - " & request.form(key) & "<BR>"
next

it lists them all out of order, how could I do a logic to get all
of them on the same order that was put on html?

You can't do it in ASP. The HTML specification *does* require it for
building the form data set...

"The control names/values are listed in the order they appear in the
document."

http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1


"The parts are sent to the processing agent in the same order the
corresponding controls appear in the document stream."

http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2


....but the Request.Form collection is still a collection, and therefore
subject to this:

"Unlike arrays, collections expand and contract automatically as
items are retrieved or stored. The position of an item will
also move as the collection is modified."

http://msdn2.microsoft.com/en-us/library/ms525228.aspx

I presume the collection re-orders as it is being filled with your form
data.
 
A

Anthony Jones

Paulo Roberto said:
Hi, I have a html form with a lot of fields in a such order, but when
retrieved by

for each key in request.form
response.write key & " - " & request.form(key) & "<BR>"
next

it lists them all out of order, how could I do a logic to get all of them on
the same order that was put on html?

example if I have:

Name
Address
Age
Birthday
Postal code
etc

the for each doesnt get on the order above... I need to send them via email
and must be on the same html order... can you help me?

I can't reproduce this problem. The underlying object return by
Request.Form is an implementation of IRequestDictionary. As far as I'm
aware this it is not a sorting dictionary so keys should be returned in the
original order that they were inserted.

Use www.fiddlertool.com to capture the form POST and examine the order of
fields being sent. In my IE6 and IE7 testing this appears to behave as per
the spec Dave as point to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top