Detecting which item too select in a select

From: Date: Wed, 20 Dec 2000 03:01:45 +0000
Subject: Detecting which item too select in a select
Groups: php.general 
Request: Send a blank email to php-general+get-31141@lists.php.net to get a copy of this message
hey all, I asked this question some time ago, but could not figure this one out. basically I need some way of detecting which item is selected in a form's drop down list this is the way I have been doing it in the past: <select name="foo"> <?php if ( $somevar == 1 ) { ?> <option value="1" selected>1</option> <?php } else { ?> <option value="1">1</option> <?php } if ( $somevar == 2 ) { ?> <option value="2" selected>2</option> <?php } else { ?> <option value="2">2</option> <?php } if ( $somevar == 3 ) { ?> <option value="3" selected>3</option> <?php } else { ?> <option value="3">3</option> <?php } ?> </select> you can imagine how cluncky this gets when using a large list like country codes etc.. and seeing im using FastTemplates I do not want to use this method. Any ideas would be appreciated, Regards Joseph

« previous php.general (#31141) next »