RE: Grouped checkbox elements returned and processed as a comma-separated string.
Hey gang. I've been using the above method (array[]) for a few years now, but i just read here about Group Checkbox form elements that get processed as a comma-separated string...
By giving several checkboxes the same name attribute value, you create a group of checkbox elements. The browser automatically collects the values of a checkbox group and submits their selected values as a comma-separated string to the server, significantly easing server-side form processing.
This appears to be a standard HTML feature, the way that is written. Various other HTML help web sites say the same thing.
The reason i am so interested in this, is because the form i am constructing at the moment requires the grouped checkbox elements to be stored in the database as a comma separated string!
eg.
<br/><input type=checkbox name=shape value=square> square
<br/><input type=checkbox name=shape value=circle> circle
<br/><input type=checkbox name=shape value=triangle> triangle
if user ticks, say, square and triangle... then on return to form.php, you would assume (according to that quote) that the value of $shape would be "square,triangle"
However, no matter what i try, $shape for me is ALWAYS just simple the last checkbox that was ticked (ie. in this case $shape == "triangle")
Has anyone had experience in this area, or any suggestions? If i could get this to work it would cut down a lot of code that is reconstructing the array once the form is submitted.
Cheers.