0

I need to build a widget that will let you select and order checkboxes via drag-and-drop.

Will the order that inputs exist on the page at the time the user clicks "Submit" always be the order it will be sent to the server (and thus the ordering I can use in the backend)?

For example, if the page starts with this form arrangement:

<input type="checkbox" name="items" value="Item 1">
<input type="checkbox" name="items" value="Item 2">

And at some point the DOM changes so at the time of submit it looks like this

<input type="checkbox" name="items" value="Item 2">
<input type="checkbox" name="items" value="Item 1">

Am I guaranteed that "Item 2" will appear before "Item 1" when submitted to the server?

NickCatal
  • 718
  • 7
  • 16
  • 1
    [This older question](https://stackoverflow.com/questions/4400698/is-the-order-of-inputs-in-a-post-guaranteed-for-array-inputs-in-php) asks about PHP specifically, but its answers suggest that the HTML spec does not make this guarantee (it doesn't matter what language you use on the server side because an HTTP form submission is put together by the client, not the server). – BoltClock Apr 24 '18 at 01:33
  • @BoltClock thanks! – NickCatal Apr 24 '18 at 01:38

0 Answers0