Re: checkboxes and selection lists
| From: | rija | Date: | Tue, 05 Nov 2002 06:39:07 +0000 |
| Subject: | Re: checkboxes and selection lists | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-122732@lists.php.net to get a copy of this message | ||
If you have hundred thousand elements for example if you rob up for some
country select within tierce code-
I thinks doing like the following is better
echo "<select>
<option>a
<option>b
...
<option>zz
<option selected>$value
</option>
</select>" ;
And I don't care if it could have 2 same value in the select case...
And if there aren't many value, I think the following sounds better:
echo "
<SELECT CLASS=select NAME=qual>
<OPTION ".($qual==A?" SELECTED":"").">A
<OPTION ".($qual==B?" SELECTED":"").">B
<OPTION ".($qual==C?" SELECTED":"")." >C</OPTION>
</SELECT>" ;
----- Original Message -----
From: <marco_bleeker@hetnet.nl>
To: <php-general@lists.php.net>
Sent: Tuesday, November 05, 2002 5:06 PM
Subject: [PHP] checkboxes and selection lists
Hi, as a beginner I find the way you declare variables through HTML-forms
quite straightforward. But the reverse, to put the same variables back into
a form field is not so obvious for selection lists and checkboxes. Would for
instance this be the best way:
<SELECT CLASS="select" NAME="qual">
<OPTION VALUE="A" <?=if($qual=='A'){return
'SELECTED'}?>>A</OPTION>
<OPTION VALUE="B" <?=if($qual=='B'){return
'SELECTED'}?>>B</OPTION>
<OPTION VALUE="C" <?=if($qual=='C'){return
'SELECTED'}?>>C</OPTION>
</SELECT>
or would there be something more elegant?
Thanks, Marco
----------------------------------------------------------------------------
----
Internet wordt pas leuk als je mee kunt doen. Ga naar http://www.hetnet.nl
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php