1
使用codeigniter生成表單。形式有form_dropdown()jQuery make option selected - CodeIgniter
<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);
從我通過其他Q &起皺的,我會認爲我的jQuery會做的伎倆。我是否留下了一些東西?
衛生署!感謝那。 – Bungdaddy
@Bungdaddy ..不客氣:) –