使用 codeigniter 生成表单。表单有一个 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 -->
输出
<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);
从我通过其他问答收集到的信息来看,我认为我的 jQuery 可以解决问题。我是不是遗漏了什么?