Re: Re: Getting the current value of a select field
| From: | Leif K-Brooks | Date: | Tue, 08 Apr 2003 17:13:29 +0000 |
| Subject: | Re: Re: Getting the current value of a select field | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142918@lists.php.net to get a copy of this message | ||
DO NOT USE SUCH HACKS!!! The correct way would be to use the default flag for the option tag, hopefully using a class or function to do the work for you.
Dan Joseph wrote:
This is how I do it: <select name=box>-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.<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 valuethanthis: