If they're the only input in the form, you could do something like:
foreach($_GET as $key=>$value){
if(!array_key_exists($key,$_GET)){
$_GET[$key] = 0;
}
}
//Subsitute $_POST for $_GET if it's a post form.
Paul Kaiser wrote:
Hey there,
I have around 50 checkboxes on an HTML form. Their "value"
One way you could do it is to put a hidden input before each checkbox with
the same name as the checkbox and set the value to 0.
This works because PHP will process all input fields in order overwriting
previous ones if it comes accross one with the same name..
eg..
and so on
Regard
Actually that wouldn't work becuase if you tested this you would have
noticed that no name or value at all is passed for a checkbox or radio
button that is not checked.
In this example $_POST['a'] is not set so you can not check it in a
conditional statement. One possible solution here is to
3 matches
Mail list logo