jQuery serializeArray: keep values of checkboxes/radio with same name
Hello, all,
I'm using $.serializeArray() to condense all the fields of a form into an array, JSON.stringify()-ing it and submitting that via AJaX. Works GREAT, as long as there are not any checkboxes that have the same name. Because an associative array cannot have duplicate keys, the last checked checkbox value is the only one being sent. Any ideas on how to get _all_ checked values to be sent? ie:
<input type="checkbox" id="unique_1" name="airliner-0" value="FOO" />
<input type="checkbox" id="unique_2" name="airliner-0" value="BAR" />
<input type="checkbox" id="unique_3" name="airliner-0" value="PHU" />
<input type="checkbox" id="unique_4" name="airliner-0" value="VAR" />
If the second and fourth checkboxes are checked, serializeArray() will first set key 'airliner-0' to 'BAR', then set it to 'VAR'. How can I get both values sent?
V/r,
^ _ ^
