Alrighty then, howdy first off; quick question I have a form that has multiple check boxes with the same name (i.e. –
<input type="checkbox" name="myname[]" value="1" />
<input type="checkbox" name="myname[]" value="1" />
<input type="checkbox" name="myname[]" value="2" />
<input type="checkbox" name="myname[]" value="3" />
<input type="checkbox" name="myname[]" value="4" />
)
I am not using JQuery as I don’t need that much baggage it is a very simple script that does does what is says on the tin, just serialize a form for use in an ajax post request. I would like to know though how to serialize the multiple checkboxes above for correct use in php.
I think the easiest way would be to grab all the checkboxes with
document.getElementsByNameand loop to get what’s checked.I assume PHP can treat a comma-delimited list of values as an array: