Using codeigniter to generate form. The form has a form_dropdown()
<div class="control-group">
<?php
foreach ($clients as $client => $clientValue) {
$option[$clientValue['clientName']] = $clientValue['clientName'];
}
echo form_label('Client Name:', 'client');
echo form_dropdown('client', $option);
?>
</div><!-- /control-group -->
Output
<select name="client">
<option value="Mike">Mike </option>
<option value="Sissel Bygton">Sissel Bygton</option>
<option value="Calli Crass">Calli Crass</option>
</select>
Javascript/jQuery
var clientName = json.selected_gallery[0].clientName; //clientName retrieved from DB
//alert box to confirm clientName for this example lets say it's Mike
alert(clientName)//output Mike
//Client Select name
$('select.client').val(clientName);
From what I’ve gathered through other Q&A, I would think that my jQuery would do the trick. Am I leaving something out?
Selector supposed to be
If you want to access it using a class then
Selector for the above is