Jason
Jason

Reputation: 95

Reorder inputs before submiting form

Is there any way to reorder or manipulate a set of inputs before posting to a script for processing? I'm able to reorder the elements in the DOM no problem, but getting this to happen after the user presses the submit button and before the browser makes the POST is a bit tricky. I'm using the ajaxForm plugin in jQuery. There is a beforeSubmit callback, but this doesn't seem to allow me to reorded the inputs.

Upvotes: 2

Views: 340

Answers (3)

Jason
Jason

Reputation: 95

$('#form').ajaxForm({ beforeSerialize: orderInputsFunction });

This works. With the jQuery Form Plugin, you can manipulate the form using a call back function with the beforeSerialize option.

In my unfortunate case, I'm working with a PHP script that assumes certain post variables will be in a particular order.

Upvotes: 1

hobodave
hobodave

Reputation: 29303

There is no good reason to want to do this.

Upvotes: 1

rmeador
rmeador

Reputation: 25704

As far as I know, the order the inputs are sent to the server is not guaranteed by the spec (correct me if I'm wrong). So what's the point of reordering them? I don't see why this is useful.

Upvotes: 2

Related Questions