Reply to Re: Category checkboxes problem

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация