Hi I have the below example form
<form id="search" method="GET" action="/results">
<input type="text" name="name">
<input type="checkbox" name="rating" value="1">
<input type="checkbox" name="rating" value="2">
<input type="checkbox" name="rating" value="3">
<input type="checkbox" name="rating" value="4">
<input type="checkbox" name="rating" value="5">
<input type="submit" value="Submit" name="submit">
</form>
When I submit the form after selecting some of the rating checkboxes and use JQuery serialize() as shown below
$('#search').submit(function() {
var $form = $(this);
var strFormData = $form.serialize();
//var objFormData = $form.serializeArray();
//var strFormDataParamResult = $.param(objFormData);
});
I get an example for strFormData like this
"name=help&rating=1&rating=2&rating=3"
Is there a way to combine any params with the same name into this result
"name=help&rating=1,2,3"
by manipulating the result of serializeArray() and then using $.param(..) ?
If so does anyone have an example of this?
Thanks for any help.
This was my solution in the end.. serializeArray and manipulating the object that way seemed a bit complicated, the below isn’t much better but it does what I want.