RE: [PHP] Dynamic Drop-down list
| From: | DanO | Date: | Fri, 09 Feb 2001 01:05:48 +0000 |
| Subject: | RE: [PHP] Dynamic Drop-down list | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-38857@lists.php.net to get a copy of this message | ||
the 'SELECTED' attribute will select an item in a dropdown list.
by default, with no SELECTED attribute, the first item will be shown and
selected.
make sense?
DanO
-----Original Message-----
From: Todd Cary [mailto:todd@aristesoftware.com]
Sent: Thursday, February 08, 2001 5:00 PM
To: php-general@lists.php.net
Subject: [PHP] Dynamic Drop-down list
I create a Drop-down from a DB table. All works as expected *except*
the default item (the one showing to the surfer) is the last in the
list. Is there a way I can have the first item show?
Todd
/* Make a drop-down */
function make_dropdown($ddName, $itemList, $first) {
if (count($itemList)) {
echo("<SELECT NAME=" . $ddName . ">");
if ($first) {
echo('<OPTION VALUE="**" SELECTED>' . $first);
};
while (list ($key, $val) = each ($itemList)) {
echo('<OPTION VALUE="' . $key . '" SELECTED>' .
$val);
};
echo("</SELECT>");
};
};
--
Todd Cary
Ariste Software
todd@aristesoftware.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net