|
Posted by David Haynes on 05/19/06 04:54
Andy Jeffries wrote:
> On Thu, 18 May 2006 08:35:34 -0400, David Haynes wrote:
>
> 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:
Understood, but many folks are more comfortable with testing
$_POST[$key] = 'OFF' or 'ON', than testing ! isset($_POST[$key]) for OFF
and $_POST[$key] == 'ON' for ON.
A lot of this sort of processing occurs in switch statements which
forces the isset() test to be performed prior to entry.
It's can sometimes be clearer to say:
switch($_POST[$key]) {
case 'ON':
break;
case 'OFF':
break;
}
than,
if( $_POST[$key] == 'ON' ) { .. } else { ... }
even though it is also valid and often used.
It's up to the programmer to decide how they want to process the data.
> I just don't see what practical advantage having a hidden input element
> preceding each checkbox gives.
>
> Cheers,
> Andy
Practical? That's debatable. Sometimes useful? See above. Personally, I
think it is a weakness in the <input type="checkbox"> specification not
to pass the negative case (OFF) to the server. If they really thought
this was a good idea, why isn't an <input type="text"> also not sent if
the value is empty?
-david-
[Back to original message]
|