这里我想选择选项 (选择所选的结果) 我的模态形式选择:
<select id="doctor2" name="doctor2">
<? foreach($staff as $doctor){?>
<option value="<?=$doctor['staff_id']?>"><?=$doctor['name']?></option>
<?}?>
</select>
如何选择ajax json数据响应选择选项:
$('.tg-invoices').on('click', '.item-edit', function(){
var id = $(this).attr('data-id1');
$.ajax({
type: 'ajax',
method: 'get',
url: '<?=base_url()?>Clinic/editAppointment',
data: {id: id},
async: false,
dataType: 'json',
success: function(data){
$("#doctor2 option[value="+data.doctor+"]").attr("selected","selected");
},
error: function(){
alert('Could not Edit Data edit');
}
});
});