Maybe this is an easy answer, and im just not seeing it, but ill ask it anyway. So i have a search form for my website. The search form includes a category section where the user can select items from different categories, all of which are checkboxes. They all have the same name so that I can use some javascript to select all and select none. I need to use php $_GET so that I can add arguments to the url so that i can get back to the criteria that the user originally searched.
html:
<input name="catID[]" id="catID_10" type="checkbox" value="10" />
<input name="catID[]" id="catID_11" type="checkbox" value="11" />
<input name="catID[]" id="catID_12" type="checkbox" value="12" />
...
The url after the from has been submitted, the actual brackets are transformed into html string form and is formatted like "catID%5B%5D=10&catID%5B%5D=11&catID%5B%5D=12"
So im wondering, is there some javascript i can perform, once the form is submitted to change the name of each checkbox so that it will format right in the url but not mess up the other select all/select none functionality?
That's perfectly normal for a php-style array in a URL. You'll find that if you do print_r($_GET)
, you'll get something like:
array(
'catID' => array(
0 => 10,
1 => 11,
2 => 12
)
'otherparameter' => 'value'
)
and can get at the individual checkbox values with a simple
if (is_array($_GET['catID'])) {
foreach($_GET['catID'] as $catID) {
...
}
}