I have a drop down list that is populated by a query against a database (run from a function since this list is used in multiple locations in the website. I'm curious if there is a way to choose an option as the default out of that list after the fact?
Basically my function returns a variable that is a list similar to below that I wrap in <option></option> brackets.
When the page loads it has another query that returns a value that corresponds to one of the option values from the above list. I would like THAT option to then be selected option so the end user can see what the original value was, but can choose a different one if they are editing this record.
Is there a way to dynamically add the selected value to the results returned in the variable? Or should I just run an additional query against the database the would retrieve the ABC, DEF, GHI, etc as appropriate based on the value returned from the main query?
I realize I kind of went a bit around and around in describing this, hopefully you get the general idea and you have some suggestions on the best way to address this.