Re: check boxes... set the VALUE or just echo CHECKED????
| From: | Bobo Wieland | Date: | Tue, 06 Jul 2004 16:55:31 +0000 |
| Subject: | Re: check boxes... set the VALUE or just echo CHECKED???? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24119@lists.php.net to get a copy of this message | ||
With xhtml syntax which I prefer it should be:
<input type='radio' name='search' value='something'
checked='checked' />
.bobo
----- Original Message -----
From: "Gryffyn, Trevor" <TGryffyn@air-cargo-inc.com>
To: "[PHP-WIN]" <php-windows@lists.php.net>
Cc: "Leo G. Divinagracia III" <ldivinag@csuhayward.edu>
Sent: Tuesday, July 06, 2004 3:54 PM
Subject: RE: [PHP-WIN] check boxes... set the VALUE or just echo CHECKED????
For HTML form elements that can be checked or selected or whatever, I
like to do something like this:
if ($conditionistru) { $checked = " CHECKED" } else { $checked = ""; }
echo "<input type=\"radio\" name=\"search\"
value=\"something\"$checked>";
If I was doing this for a combo/option box, I'd have a list of the
options in an array, use a "foreach" to create the <option> entries and
check the value from the array against the currently used value and
assign $checked = " CHECKED" if they match. This way, the previously
selected option is always auto-selected in your web form.
Part of the reason I put the space inside the quotes with the CHECKED is
so the HTML that's output is nice and clean. Nothing like seeing a
blank space and wondering what got omitted.
I don't know if that's the proper way.. But I don't see anything wrong
with it stylistically and it works for me.. And seems to qualify for
'easy' in my book.
-TG
> -----Original Message-----
> From: Leo G. Divinagracia III [mailto:ldivinag@csuhayward.edu]
> Sent: Monday, July 05, 2004 4:21 AM
> To: [PHP-WIN]
> Subject: [PHP-WIN] check boxes... set the VALUE or just echo
> CHECKED????
>
>
> i'm thinking of just adding the CHECKED word to the ECHO'ed HTML
> statement instead of dealing with the VALUE.
>
> what's the "proper" vs the "easy" way?
>
> thanks... i googled a few pages and it really didnt give a
> good result.
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php