|
Posted by Andy Jeffries on 05/18/06 16:57
On Thu, 18 May 2006 08:35:34 -0400, David Haynes wrote:
> A trick when using checkboxes is to use a hidden field to record the 'off'
> value, then have the checkbox.
Why bother with that?
> If the checkbox is checked the value will be 'ON'; if the checkbox is
> not set, the value will be whatever you set the hidden value to. ('OFF'
> in the example)
If you don't precede it with a hidden value, it will be either undefined
(normally empty) or the value you chose "ON". So then you continue with
the same code you had before:
> foreach( $_POST as $key => $value ) {
> if( $value == 'ON' ) {
> $del = "delete from catalogue where id = $key"; mysql_query($del) or
> die("...");
> }
> }
> }
I just don't see what practical advantage having a hidden input element
preceding each checkbox gives.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos
[Back to original message]
|