In order?
am 26.12.2007 19:12:18 von 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) & "
"
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!!!
Re: In order?
am 26.12.2007 19:34:16 von Jon Paal
retrieve them individually and reassemble in the order desired.
Re: In order?
am 26.12.2007 21:55:53 von daddywhite
On 26 Dec, 18:34, "Jon Paal [MSMD]"
com> wrote:
> 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
Re: In order?
am 27.12.2007 20:54:00 von Dave Anderson
Paulo Roberto wrote:
> 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) & "
"
> 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.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Re: In order?
am 28.12.2007 00:28:00 von Anthony Jones
"Paulo Roberto" wrote in message
news:OH1xlt%23RIHA.5288@TK2MSFTNGP04.phx.gbl...
> 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) & "
"
> 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.
--
Anthony Jones - MVP ASP/ASP.NET