CodeIgniter Forums

Full Version: how i can show combobox value in ajax
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
this is my edit view in ajax

<script type="text/javascript">
function edit(id){
type : "POST",
data : "",
url : "<?php echo site_url('pangkat/edit')?>/"+id,
success : function(data){

obj = JSON.parse(data);
var html = ''+
'<form id="form-edit">'+

      '<div class="form-group" >'+
        '<label class="control-label labelnya"><i class="ion ion-home"></i>&nbsp; Golongan : </label>'+
'<select class="persons" id="id_golong" name="id_golongan" style="width: 100%" data-placeholder="Pilih Golongan">'+
<?php foreach($golongan as $row){?>
'<option value="<?php echo $row['ID_GOLONGAN']?>"><?php echo $row['GOLONGAN']?></option>'+
<?php }?>

this controller

public function edit($id = NULL)
$data['golongan'] = $this->M_golongan->get();
$data = $this->M_pangkat->get($id);
echo json_encode(array(
'id_pangkat' =>$data['ID_KENAIKAN_PANGKAT'],
'id_pegawai' =>$data['ID_PEGAWAI'],
'id_golongan' =>$data['ID_GOLONGAN'],
'sk_pangkat' =>$data['SK_PANGKAT'],
'tgl_mulai' =>date('d-m-Y ',strtotime($data['TGL_MULAI'])),
'tgl_terhitung' =>date('d-m-Y ',strtotime($data['TGL_TERHITUNG']))