• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Multiple Selects - order of the selected options

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I was wondering if the order of selected options in an html multiple select control is preserved. For example, let us say I have the following options in a multiple select box:

option1
option2
option3
option4
option5
and the user selects option1 and option3. What is the order I should expect it on the web server? Will it always be option1 followed by option3?
Could you also please point me to any authentic documentation on this.
Thanks in advance!!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is almost completely random, I am sure it will come out to Option 1 and Option 3 most of the time, but I would not count on it.
Browsers might do things in different manners.
I think it just follows the Form element array, I never really looked into this.
Why is this going to effect you?
Eric
 
Aj Manch
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These options actually represent column names and the results of a certain operation have to be displayed to the user in that particular order. The user could dynamically add more fields or remove the existing fields or change the order of the fields (using a up/down button) in that select box.
I know that if you have the fields with same names (for example, two text boxes with the same name), we cannot predict the order in which the fields finally make it to the web server.
However, in this case it seems reasonable (to me atleast that the order be preserved. I can use JavaScript to order the fields and send it to the server but I am looking for what the spec has to say in this respect.
Any ideas?
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing in the HTTP specification guarentees an order of any kind. In practice I have found that the order actually delivered usually has to do with how the entries are ordered within the control, and not with any selection order on the part of the user. But again, no guarentees.
hth,
bear
 
reply
    Bookmark Topic Watch Topic
  • New Topic