One more form question
| From: | David Chamberlin | Date: | Fri, 03 Jan 2003 20:27:27 +0000 |
| Subject: | One more form question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-130152@lists.php.net to get a copy of this message | ||
OK, last one was answered quickly and successfully (thank you!), so here's another one.
Is there an easy way to set something in a select list to be selected? Right now I'm doing a real brute-force method. e.g.,
echo "<td><select name=\"disp_address\">";
$choices = array( 'pub' => 'On Public Page',
'members' => 'Only on Members Page',
'nodisp' => 'Do not Display' );
foreach ( $choices as $key => $choice ) {
$selected = '';
if ( strcmp( $key, $member_info->display_address ) == 0 ) {
$selected = 'selected';} echo "<option value=\"$key\" $selected>$choice"; } echo '</select></td>'; I've got to imagine there's a better way .... Thanks, Dave