Does anyone know how to output checkboxes value in a comma separated way?
Lets assume that I have 2 checkboxes:
<input id="filetype_photo" name="type" type="checkbox" value="photo" ><input id="filetype_graphic" name="type" type="checkbox" value="graphic" >
If I retrieve them with $_GET I get the following url:
- sitename.com?type=photo&type=graphic
My goal is to get the following url if both checkboxes are selected: - sitename.com?type=photo,graphic
I have tried using array of checkboxes renaming them to name[] and using the following function to litertae trough the results:
$type=$_GET['type'];
while (list ($key,$val) = @each ($type)) {
echo $val;
}
but this gives me the checkboxes values but does not solve the url problem. Moreover, the urls gets messed up by changing
type=photo to &type%5B%5D=photo
Any ideas?
P.S. I need to work it out server side
Use:
And your
$type=$_GET['type']will be an array.