|
Posted by noone on 03/24/06 22:04
Ken Robinson wrote:
>> On Fri, 24 Mar 2006 08:34:51 -0800, fiziwig wrote:
>> > I can do
>> >
>> > <INPUT TYPE="checkbox" NAME="cb123" VALUE="on">Category Description
>> > <INPUT TYPE="checkbox" NAME="cb137" VALUE="on">Category Description
> A different way to do this is
> <INPUT TYPE="checkbox" NAME="cb[123]" VALUE="on">Category Description
> <INPUT TYPE="checkbox" NAME="cb[137]" VALUE="on">Category Description
> Then in you PHP, you can do
> <?php
> if (isset($_POST['cb']))
> foreach $_POST['cb'] as $key=>$dmy)
> echo 'You chose catagory ' . $key . '<br>';
> ?>
> This works because only those checkboxes that are actually checked are
> sent to your script.
> Ken
or another way is:
-----------begin cut here------------------
<?php
if (isset($_POST['cb']))
{
$cb = implode(",",$_POST['cb']);
echo 'You chose catagory ' . $cb . '<br>';
}
else {
?>
<html><head><title>test </title></head><body>
<h2><center>test </h2></center><p>
<form method=post>
<INPUT TYPE="checkbox" NAME="cb[]" VALUE="123">CB 123<br>
<INPUT TYPE="checkbox" NAME="cb[]" VALUE="133">CB 133<br>
<INPUT TYPE="checkbox" NAME="cb[]" VALUE="143">CB 143<br>
<INPUT TYPE="checkbox" NAME="cb[]" VALUE="153">CB 153<br>
<INPUT TYPE="checkbox" NAME="cb[]" VALUE="167">CB 167<br>
<input type=hidden name=flag value=1><input TYPE=submit value=Submit>
<input TYPE=reset value=Reset></form>
</body></html>
<?php } ?>
-----------end cut here------------------
If you checked the appropriate boxes you get:
You chose catagory 123,133,153
[Back to original message]
|