In order?

Discussion in 'ASP General' started by Paulo Roberto, Dec 26, 2007.

  1. 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!!!
    Paulo Roberto, Dec 26, 2007
    #1
    1. Advertising

  2. Paulo Roberto

    daddywhite Guest

    On 26 Dec, 18:34, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
    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
    daddywhite, Dec 26, 2007
    #2
    1. Advertising

  3. 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) & "<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.



    --
    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.
    Dave Anderson, Dec 27, 2007
    #3
  4. "Paulo Roberto" <> wrote in message
    news:OH1xlt%...
    > 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.

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Dec 27, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shixx
    Replies:
    0
    Views:
    926
    Shixx
    Jun 8, 2004
  2. Neil Zanella
    Replies:
    1
    Views:
    484
    Jonathan Bromley
    Oct 17, 2003
  3. Soren Kuula
    Replies:
    2
    Views:
    496
    Soren Kuula
    Feb 1, 2004
  4. cspoh
    Replies:
    0
    Views:
    244
    cspoh
    Jul 31, 2003
  5. Stephan Kämper
    Replies:
    2
    Views:
    232
    Stephan Kämper
    Jan 18, 2004
Loading...

Share This Page