I have a drop down generated with php.
<select name="diploma" id="diploma-<? echo $edu['id']; ?>">
<? foreach($diplomas->result_array() as $diploma) {
echo "<option value=".$diploma['id'].">".$diploma['name']."</option>";
} ?>
</select>
I also have <? echo $edu['diploma']; ?> which is a value from the database. I want to add selected="selected" to the option in the drop down which matches this value. Should I just use jquery? What’s the best way to do this?
You can check inside the loop like this:
Or to make the code shorter: