I’d like to be able to remember the selected value of my dropdownlist.
Whether it be from java, a Session or Cookie and have it selected accordinaly after postback. Any help would be much appreciated.
Below is my code:
<select name="Name" onChange="showSelected(this.value)">
<?php
$qRtu = "SELECT ID, Name From tblOption";
$result = mysql_query($qRtu);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $data['ID'] ?>" ><?php echo $data['Name'] ?></option>
<?php } ?>
</select>
You will need to put in the HTML to allow the form control to select a single selected option, something along the lines of:
The
'some_value'is something that you will need to grab from your database, or session, or cookie, or whereever you plan to grab the default value of the select box from.