Re: check boxes... set the VALUE or just echo CHECKED????

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx>
To: "" <php-windows@xxxxxxxxxxxxx>
Cc: "Leo G. Divinagracia III" <ldivinag@xxxxxxxxxxxxxx>
Sent: Tuesday, July 06, 2004 3:54 PM
Subject: RE:  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@xxxxxxxxxxxxxx]
> Sent: Monday, July 05, 2004 4:21 AM
> To: 
> Subject:  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

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux