Jump to content

Checkbox question, testing for checked


dwest

Recommended Posts

this is untested, but you could also do this:
[code]
<?php
if(isset($_POST['checkboxarray'])){
$true  = 0;
$false = 0;
foreach($_POST['checkboxarray'] as $key => $val){
if($val == true){
$true++;
}else{
$false++;
}
}
echo $true .' checkboxes were checked<br />\n';
echo $false .' checkboxes were NOT checked<br />\n';
}

echo '<form method="post" action="'. $_SERVER['php_self'] .'">';

for($i = 0; $i <= $num_of_checkboxes; $i++){
echo '<input type="checkbox" name="'. $checkboxarray[$i] .'">';
}

echo '</form>';
?>
[/code]
[quote author=dwest link=topic=124010.msg513320#msg513320 date=1169746965]
Many thanks to both of you for clarifying this for me!  It's amazing how dang simple the solutions to some of my stumbles are.  Makes one feel pretty dumb sometimes  ::)
Live and learn...
[/quote]
don't sweat it man. we've all asked our fair share of questions around here.
just remember: there are no dumb questions. just dumb people =P.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.