I have a text field: <input type="text" class="field blink" name="j-state[]" id="j-state"/>
The data in it will be a comma-separated list of states, e.g. New York,New Jersey.
I am using serialize() to grab the form’s data. I want to form an array of these states, and pass the array along with serialized data.
Can any help me to achieve this?
Thanks in advance.
I did not want to have to deal with your name with the dash so I renamed it thus:(you can deal with that issue yourself otherwise if you like)
Get some code from this questions answer: Convert form data to JavaScript object with jQuery
then do this:
You can then use
toJSON()(google that) to properly form that ms object and send it off – I will leave that exercise to you.And, last off, a fiddle for you to play with: http://jsfiddle.net/MHVeC/