Re: selected problem

From: Date: Fri, 26 Apr 2002 18:02:10 +0000
Subject: Re: selected problem
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-18838@lists.php.net to get a copy of this message
"Its Me" <fotna@egypt.net> wrote in message news:200204260839.g3Q8daf31303@mail9.bigmailbox.com... > i have the file: > edit_profile.php Just curious: why do you have May 15th and October 6th listed as locations? <?php if (!isset($location)) $location = ""; $locations[] = array( "" => "Choose City", "Abou Redes" => "Abou Redes", "Abou-Zabal" => "Abou-Zabal", "Al Arish" => "Al Arish", "Al Mahala" => "Al Mahala", // ... etc, etc... "Zafrana" => "Zafrana", "Zagazik" => "Zagazik" ); echo "\n<select name='location'>"; foreach($locations as $value => $text) echo "\n\t<option" .($location == $value ? " selected" : "") ." value='$value'>" .$text ."</option>"; echo "\n</select>"; ?> NOTE: 1. That is a pretty God-awful long list; is there any way to subdivide it logically? Maybe use a pair of Javascript-coupled selection-boxes - use the first box to specify the first letter of the desired name, then the second box provides (a much shorter list of) all destinations beginning with that letter. 2. If your option-value and option-text are always identical, there is no need to specify the value separately (it defaults to the text).

« previous php.db (#18838) next »