Dropdown List default Value set to records value Help

Not sure how to go about this task but I imagine it requires some sort of foreach loop

I have a drop down list populated by a label called LST_Type, this table only exists to provide options for this dropdown list

The value selected on the dropdown menu gets written to a table called “assets”. when the users clicks away from the form (using ajax)

Here is what I need to happen:

On page load the dropdown list need its default option to be whatever the current value of the record is in the “asset” table. As the only way you can insert data into this field is via the dropdown list it will always be somethig from the “LST_Type” table

The reason is that the data is written to the fields when you click away from the input boxes and unless you are editing the “Type” record it updates it to its default selection.

hope this makes sense

here is my code:

[code]

Type: <?php echo $Type; ?>

>

<?php $sql = mysql_query("SELECT Type FROM LST_Type"); while ($row = mysql_fetch_array($sql)){ echo "" . $row['Type'] . ""; } ?> [/code]

Take a look at this tutorial I have, it will show you how to do what you are asking.
http://amecms.com/article/Retaining-Drop-down-Selection-After-Form-Submit

Sponsor our Newsletter | Privacy Policy | Terms of Service