I have 5 fields of a form and I would like, through a function, to rearrange the values of them by having the first fields filled and the last ones empty, according to the existing values in ascending order. >
For example:
HTML:
<input id="campo1" type="text" /><br>
<input id="campo2" type="text" value="uva" /><br>
<input id="campo3" type="text" /><br>
<input id="campo4" type="text" value="laranja" /><br>
<input id="campo5" type="text" /><br>
When calling the function, it would look like this:
<input id="campo1" type="text" value="uva" /><br>
<input id="campo2" type="text" value="laranja" /><br>
<input id="campo3" type="text" /><br>
<input id="campo4" type="text" /><br>
<input id="campo5" type="text" /><br>
Updating: The order of the values must obey the id
of the fields in ascending order (field1, field2 ...).