RE: [PHP] Re: Getting the current value of a select field
| From: | Dan Joseph | Date: | Tue, 08 Apr 2003 17:09:22 +0000 |
| Subject: | RE: [PHP] Re: Getting the current value of a select field | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142917@lists.php.net to get a copy of this message | ||
This is how I do it:
<select name=box>
<option
value="$_POST["var1"]">$_POST["var1"]</option>
<option value="1">Cancelled</option>
<option value="0">Not Complete</option>
</select>
If there is not $_POST variables, it'll leave it blank.
-Dan Joseph
-----Original Message-----
From: shaun [mailto:shaun@mania.plus.com]
Sent: Tuesday, April 08, 2003 1:07 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Getting the current value of a select field
Sorry here is the code!
<tr>
<td>Status</td>
<td>
<select name="booking_status">';
if ($booking_status == '2'){
echo '<option value="2" selected>Complete</option>
<option value="1">Cancelled</option>
<option value="0">Not Complete</option>';
}else if ($booking_status == '1'){
echo '<option value="2">Complete</option>
<option value="1" selected>Cancelled</option>
<option value="0">Not Complete</option>';
}else{
echo '<option value="2">Complete</option>
<option value="1">Cancelled</option>
<option value="0" selected>Not Complete</option>';
}
echo '</select>
"Shaun" <shaun@mania.plus.com> wrote in message
news:20030408170634.53894.qmail@pb1.pair.com...
> Hi,
>
> Is there a more elegant way to show a select box with the correct value
than
> this:
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php