Reputation: 92651
I have a tagging plugin which maintains it's selection of tags in two forms. One is an internal array. The other is by having an html select which only contains the tags with all selected which allows the tagging plugin to act like a normal element if the plugin is part of a form.
I have been asked to implement re-ordering. I know how to do this and adjust the array. The select has me a bit puzzled as to how different browsers handle the order.
In what order are the selected items submitted as part of the form? In the order they are selected? Alphabetically/numerically by value? Or simply top to bottom with the selected items?
Upvotes: 4
Views: 3406
Reputation: 1083
According to the HTML spec, the form values are to be submitted in the order they appear in the document:
See http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 for more details.
However, just because that's what the spec says doesn't mean that's what browsers actually do. Browsers are notorious for not following the w3c specs. It's probably safer for you to track the order in a separate <input type="hidden">
element.
Upvotes: 6