• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how i can show combobox value in ajax

#1
this is my edit view in ajax

<script type="text/javascript">
function edit(id){
$("#form-edit").remove();
$.ajax({
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">'+
'<option></option>'+
<?php foreach($golongan as $row){?>
'<option value="<?php echo $row['ID_GOLONGAN']?>"><?php echo $row['GOLONGAN']?></option>'+
<?php }?>
'</select>'+
       '</div>'+


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']))
));
}
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.