note 30103 added to faq.html
| From: | Ronan dot Minguy at wanadoo dot fr | Date: | Thu, 06 Mar 2003 13:53:17 +0000 |
| Subject: | note 30103 added to faq.html | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44940@lists.php.net to get a copy of this message | ||
USING CHECKBOXES IN A FORM
If you're using a checkbox in a form and want test if the checkbox was checked, you must not
specify any value in the checkbox input, otherwise it won't work.
Id est :
echo "<input type=\"checkbox\" name=\"cb\">
will work
you can then test after submitting the form like this
if ($cb)
{
//what to do if the box was checked
}
else
{
//what to do if the box wasn't checked
}
but
echo "<input type=\"checkbox\" name\"cb\" value\"$cb\">
won't work. If your using the same "if" instruction than above, it will be always
false.
Believe me I spend hours wondering why it wasn't working!
Ronan
--
http://www.php.net/manual/en/faq.html.php
http://master.php.net/manage/user-notes.php?action=edit+30103
http://master.php.net/manage/user-notes.php?action=delete+30103
http://master.php.net/manage/user-notes.php?action=reject+30103