Multi Select Dropdownlist Preselection
I would like to fill the
Solution 1:
Yes it is... assuming you are populating the select with the results from a database query, you will have something like this: (note: just code meant to learn you, it will require adjustment before you get it working for your particular app)
$options = mysql_query(/*your query here no idea what you're retrieving*/);
?><select multiple="multiple"><?php
while ($option = mysql_fetch_assoc($options)) {
$selected = ($option['active']) ? 'selected="selected"':'';
echo '<option '.$selected.' value="YOUR_VALUE">YOUR_NAME</option>';
}
?></select><?php
Note: Replace YOUR_VALUE and YOUR_NAME with data retrieved also from the database. Not knowing what it is, couldn't tailor the code for your specific app more.
Post a Comment for "Multi Select Dropdownlist Preselection"