Re: Trying to keep a dropdown selection sticky
| From: | Peter Jackson | Date: | Sat, 05 Jul 2008 11:30:14 +0000 |
| Subject: | Re: Trying to keep a dropdown selection sticky | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276301@lists.php.net to get a copy of this message | ||
Michael S. Dunsavage wrote:
I have a form I want to keep sticky, but I can't figure out how. I got all the <INPUT>'s to be sticky.... The select script <?php echo '<strong>State</strong><br>'; echo '<select name="State">'; foreach ($state_list as $key => $value) { echo "<option value=\"$key\"> $value</option>\n"; } echo '</select>'; echo '<br>'; ?>If I'm reading this correctly you mean if the value has been selected before select it again? If so way I did it was by checking the database value eg echo "<option value=\"$key\" if ($row[id] == $key) {
print "SELECTED"; }echo "> $value </option>\n"; Peter Jackson