Does serializeArray() only work on input and textarea. how about select, checkbox, and radio buttons. I need to know which option is selected from select box and whether checkbox is checked or not. How can we get all this info in an array.
Asked
Active
Viewed 5,195 times
1 Answers
6
It should serialize all inputs, select, checkboxe etc...I noticed you were missing names on some of your elements, that could be why you are not seeing all elements being serialized.
<form>
<input type="text" name="name" value="John"/>
<input type="text" name="password" value="password"/>
<input type="text" name="url" value="http://asd.org/"/>
<input type="checkbox" value="test" name="chktest" checked="checked"/>
<select name="stuff" id="validateAs">
<option value="letnum">1</option>
<option value="numbers">2</option>
<option value="letters">3</option>
<option value="url">4</option>
<option value="email">5</option>
</select>
</form>
Something like this should serialize correctly. Here's the Documentation for serializeArray()
.

Austin M
- 594
- 1
- 4
- 19
-
2It's not getting the checked option because it has no name attribute. If there is no name attribute or is not checked it doesn't get serialized, same with the select option. The code above should work. – Austin M Feb 19 '11 at 05:37