autocomplete tidak jalan

sondang · Aug 16, 2016
siang semuanya, saya sudah buat autocomplete, dan jalan kalau menggunakan text, tapi kalau radio button tidak bisa nampil sesuai yang di pilih, solusinya bagaimana ya?
<?php
include "../../koneksi.php";
$term = $_GET['term'];
$sql = "SELECT * FROM tb_pasien WHERE nomor_rekam_medis LIKE '%".$term."%'";
$hs = mysql_query($sql);
$json = array();
while($data = mysql_fetch_array($hs)){
	$json[] = array(
		'label' => $data['nomor_rekam_medis'] ." - ". $data['nama_pasien'],
		'value' => $data['nomor_rekam_medis'],
		'nama_pasien' => $data['nama_pasien'],
		'jenis_kelamin_pasien' => $data['jenis_kelamin_pasien']

	);
}
header("Content-Type: application/json");
echo json_encode($json);
?>
<?php

$aksi="module/transaksi_pasien/transaksi_pasien_aksi.php";


switch(isset($_GET["aksi"]) ? $_GET["aksi"] :'"'){
default:

?>
<hr/>

  <div class="box box-solid box-primary">
    <div class="box-header">
    <h3 class="btn btn disabled box-title">
    <i class="fa fa-user-md"></i>
    Data Pasien </h3>
    <a class="btn btn-primary pull-right" href="?module=transaksi_pasien&aksi=tambah">
    <i class="fa  fa-plus"></i> Tambah Data</a> 
    </div>    
  <div class="box-body">
  <table id="example1" class="table table-bordered table-striped">
<thead>
  <tr class="text-blue">
    <th>TGL/JAM INPUT</th>
    <th>MR</th>
    <th>NAMA PASIEN</th>
    <th>JK</th>
    <th>NAMA POLI</th>
    <th>NAMA BAGIAN</th>
    <th>AKSI</th>
  </tr>
</thead>

<tbody>
<?php
$sql = "SELECT * FROM tb_pasien a, tb_distribusi b, tb_poli c, tb_bagian d where a.id_pasien=b.id_pasien AND b.id_poli=c.id_poli AND b.id_bagian=d.id_bagian AND status_distribusi='TERIMA' order by tanggal_input DESC";
$tampil = mysql_query($sql);
$no=1;
while ($data = mysql_fetch_array($tampil)) { 
$Kode = $data['nomor_rekam_medis'];?>

  <tr>
  <td><?php echo date('d-m-Y', strtotime($data['tanggal_input'])) .", ". $data['jam_input']; ?></td>
  <td><?php echo $data['nomor_rekam_medis']; ?></td>
  <td><?php echo $data['nama_pasien']; ?></td>
  <td><?php echo $data['jenis_kelamin_pasien']; ?></td>
  <td><?php echo $data['poli']; ?></td>
  <td><?php echo $data['bagian']; ?></td>
  
  <td align="center">&nbsp;&nbsp;|
    <a class="fa fa-pencil-square-o edit"   data-toggle="tooltip" title="Edit Data <?php echo $data['id_pasien'];?>" href="?module=transaksi_pasien&aksi=edit&id_pasien=<?php echo $data['id_pasien'];?>"></a> &nbsp;&nbsp;|
    <a class="fa fa-trash hapus"   data-toggle="tooltip" title="Hapus Semua Data pasien" href="<?php echo $aksi ?>?module=transaksi_pasien&aksi=hapus&id_distribusi=<?php echo $data['id_distribusi'];?>"></a>&nbsp;&nbsp;|
    <a class="fa fa-motorcycle beset" data-toggle="tooltip" title="Antar <?php echo $data['id_pasien'];?>" href="?module=transaksi_antar&aksi=edit&id_pasien=<?php echo $data['id_pasien'];?>"></i></a>&nbsp;&nbsp;|
    <a class="fa fa-undo kembali" data-toggle="tooltip" title="Kembali <?php echo $data['id_pasien'];?>" href="?module=transaksi_kembali&aksi=edit&id_pasien=<?php echo $data['id_pasien'];?>"></i></a>&nbsp;&nbsp;|
    <a class="fa fa-bed beset" data-toggle="tooltip" title="Rawat <?php echo $data['id_pasien'];?>" href="?module=transaksi_rawat&aksi=edit1&id_pasien=<?php echo $data['id_pasien'];?>"></i></a>&nbsp;&nbsp;|
  </td>
  <?php
  }
  ?>
  </tr>
      </tbody>
    </table>
  </div>
</div>
<?php 
break;
case "tambah": 
?>
<form class="form-horizontal" role="form" method="post" action="<?php echo $aksi?>?module=transaksi_pasien&aksi=tambah" >
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
  <h3 class="box-title">DATA PASIEN</h3>
  <div class="box-tools pull-right">
  <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
  <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
  </div>
</div>
<div class="box-body">
<form class="form-horizontal" action="<?php echo $aksi?>?module=kelas&aksi=tambah" role="form" method="post">
<div class="form-group">
    <label class="col-sm-4 control-label">Tanggal Register</label>
    <div><div class="col-sm-2">
            <?php
              date_default_timezone_set("Asia/Jakarta");
              $jam_input = date("H:i:s");
              $tanggal_input = date("d-m-Y");
            ?>
      <input type="text" class="form-control" readonly name="jam_input" value="<?php echo"$jam_input";?>">
  </div>
  <div class="col-sm-2">
    <div class="input-group">
  <div class="input-group-addon">
       <i class="fa fa-calendar"> </i>
    </div>
      <input type="text" class="form-control" readonly name="tanggal_input" value="<?php echo date('d-m-Y');?>">
  </div><!-- /.input group -->
  </div></div>
  </div>
  
  <div class="form-group">
    <label class="col-sm-4 control-label">Rekam Medis</label>
    <div class="col-sm-2">
      <input type="text" autofocus required class="form-control" data-toggle="tooltip" title="Nomor Rekam Medis" onkeypress="return hanyaAngka(event)" required="required" name="nomor_rekam_medis" id="nomor_rekam_medis" placeholder="Nomor Rekam Medis" maxlength="6">
    </div>
  </div>

<div class="form-group">
  <label class="col-sm-4 control-label">Nama Pasien</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" data-toggle="tooltip" title="Nama Pasien" required="required" name="nama_pasien" id="nama_pasien" placeholder="Nama Pasien">
      <input type="text" class="form-control" data-toggle="tooltip" title="Nama Pasien" required="required" name="jenis_kelamin_pasien" id="jenis_kelamin_pasien" placeholder="Nama Pasien">
    </div>
    </div>
<div class="form-group">
  <label class="col-sm-4 control-label">Jenis Kelamin</label>
    <div class="col-sm-4">
      <input name="jenis_kelamin_pasien" type="radio" value="LAKI-LAKI" checked id="jenis_kelamin_pasien"> LAKI-LAKI &nbsp;&nbsp;
      <input name="jenis_kelamin_pasien" type="radio" value="PEREMPUAN" id="jenis_kelamin_pasien"> PEREMPUAN
    </div>
</div>
<div class="form-group">
  <label class="col-sm-4 control-label">Nama Poli</label>
    <div class="col-sm-3">
    <select name="id_poli" id="poli" class="form-control">
      <option value=" "> -- Pilih Poli -- </option>
        <?php 
              $sondang=mysql_query("select * from tb_poli");
              while($b=mysql_fetch_array($sondang)){
            ?>  
            <option value="<?php echo $b['id_poli']; ?>"><?php echo $b['poli'] ?></option>
            <?php 
            }
            ?>
    </select>
  </div>
</div>
<div class="form-group">
  <label class="col-sm-4 control-label">Nama Bagian</label>
    <div class="col-sm-3">
    <select name="id_bagian" id="bagian" class="form-control">
      <option value=" "> -- Pilih Bagian -- </option>
        <?php 
              $sondang=mysql_query("select * from tb_bagian");
              while($b=mysql_fetch_array($sondang)){
            ?>  
            <option value="<?php echo $b['id_bagian']; ?>"><?php echo $b['bagian'] ?></option>
            <?php 
            }
            ?>
    </select>
  </div>
</div>
<div class="form-group">
    <label class="col-sm-4"></label>
    <div class="col-sm-5">
      <button type="submit"name="submit" class="btn btn-primary" onclick="sweet()"><i class="glyphicon glyphicon-floppy-disk"></i> Simpan</button>
    <button type="reset" class="btn btn-danger"><i class="fa fa-refresh"></i><i> Batal</i></button>
    <button type="button" class="btn btn-danger" onclick="history.back(-1)"><i class="glyphicon glyphicon-arrow-left"></i> Back</button>
    </div>
  </div>
</div>
</div>
</div>


<?php
break;
case "edit":
$data=mysql_query("SELECT * FROM tb_pasien a, tb_distribusi b, tb_poli c, tb_bagian d where a.id_pasien=b.id_pasien AND b.id_poli=c.id_poli AND b.id_bagian=d.id_bagian AND a.id_pasien='$_GET[id_pasien]'");
$edit=mysql_fetch_array($data);

?>

<form class="form-horizontal" action="<?php echo $aksi?>?module=transaksi_pasien&aksi=edit" role="form" method="post">             

<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
  <h3 class="box-title">Data Pasien</h3>
  <div class="box-tools pull-right">
  <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
  <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
  </div>
</div>
<div class="box-body">
<form class="form-horizontal" action="<?php echo $aksi?>?module=transaksi_pasien&aksi=edit" role="form" method="post">
<div class="form-group">
    <label class="col-sm-3 control-label">Tanggal Register</label>
    <div><div class="col-sm-3">
            <?php
              date_default_timezone_set("Asia/Jakarta");
              $jam_input = date("H:i:s");
           ?>
      <input type="text" class="form-control" readonly name="jam_input" value="<?php echo"$jam_input";?>">
  </div>
  <div class="col-sm-5">
    <div class="input-group">
  <div class="input-group-addon">
       <i class="fa fa-calendar"> </i>
    </div>
    <input type="text" class="form-control" required="required" data-toggle="tooltip" name="tanggal_input" id="tanggal_input" value="<?php echo $edit['tanggal_input'];?>">
      
  </div><!-- /.input group -->
  </div></div>
  </div>
  <div class="form-group">
    <label class="col-sm-3 control-label">Rekam Medis</label>
    <div class="col-sm-8">
    <input type="hidden" class="form-control" readonly name="id_pasien" value="<?php echo $_GET['id_pasien']; ?>">
      <input type="text" class="form-control"  required="required" name="nomor_rekam_medis"value="<?php echo $edit['nomor_rekam_medis']; ?>">
    </div>
  </div>
<div class="form-group">
  <label class="col-sm-3 control-label">Nama Pasien</label>
    <div class="col-sm-8">
      <input type="text" class="form-control"  required="required" name="nama_pasien"value="<?php echo $edit['nama_pasien']; ?>">
    </div>
    </div>

<div class="form-group">
    <label class="col-sm-3 control-label">Jenis Kelamin</label>
    <div class="col-sm-8">
    <input  class="minimal" name="jenis_kelamin_pasien" type="radio" value="LAKI-LAKI" <?php if(($edit['jenis_kelamin_pasien'])== "LAKI-LAKI")
        {echo "checked=\"checked\"";};?>/> LAKI-LAKI &nbsp;&nbsp;
    <input class="minimal" name="jenis_kelamin_pasien" type="radio" value="PEREMPUAN" <?php if(($edit['jenis_kelamin_pasien'])== "PEREMPUAN")
        {echo "checked=\"checked\"";};?>/> PEREMPUAN
    </div></div>
  <div class="form-group">
  <label class="col-sm-3 control-label">Poli</label>
    <div class="col-sm-8">
    <select name="id_poli" id="poli" class="form-control">
        <?php
          $cur_poli=$edit['id_poli'];
          $q=mysql_query("select * from tb_poli");
          while($row=mysql_fetch_array($q)){ 
            $selected='';
            if($row['id_poli']==$cur_poli){$selected='selected';}else{$selected='';}
            echo "<option value='".$row['id_poli']."' ".$selected.">". $row['id_poli']." / ".$row['poli']."</option>";
            ?>
          <?php }?>
      </select>
  </div>
</div>
  <div class="form-group">
  <label class="col-sm-3 control-label">Bagian</label>
    <div class="col-sm-8">
    <select name="id_bagian" id="bagian" class="form-control">
        <?php
          $cur_bagian=$edit['id_bagian'];
          $q=mysql_query("select * from tb_bagian");
          while($row=mysql_fetch_array($q)){ 
            $selected='';
            if($row['id_bagian']==$cur_bagian){$selected='selected';}else{$selected='';}
            echo "<option value='".$row['id_bagian']."' ".$selected.">". $row['id_bagian']." / ".$row['bagian']."</option>";
            ?>
          <?php }?>
      </select>
  </div>
</div>



<div class="form-group">
    <label class="col-sm-4"></label>
    <div class="col-sm-7">
      <button type="submit"name="submit" class="btn btn-primary" onclick="sweet()"><i class="glyphicon glyphicon-floppy-disk"></i> Simpan</button>
    <input type="reset" class="btn btn-warning" value="Batal" onclick="window.history.back();">
    </div>
  </div>
</div> 

<div id="yyy" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</div></div>
</div></div>

<?php
break;
} 
?>
<!--<script src="../aset/plugins/jQuery/jq.js"></script> -->
<link rel="stylesheet" href="../aset/plugins/jQuery/jquery-ui-1.10.3.custom.css" type="text/css" media="" />
<script src="../aset/plugins/jquery/jquery-2.2.4.min.js" type="text/javascript"></script>
<script src="../aset/plugins/jQuery/jquery-ui-1.10.3.custom.min.js"></script>
<script src="../aset/dist/js/bootstrap.min.js" type="text/javascript"></script>


<script>
    function hanyaAngka(evt) {
      var charCode = (evt.which) ? evt.which : event.keyCode
       if (charCode > 31 && (charCode < 48 || charCode > 57))
 
        return false;
      return true;
    }
  </script>

  <script>
            $(document).ready(function () {
                $("#poli").select2({
                    placeholder: "--Pilih Poli--",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#id_unit").select2({
                    placeholder: "Pilih Bagian",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#bagian").select2({
                    placeholder: "--Pilih Bagian--",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#pendidikan").select2({
                    placeholder: "Please Select",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#pekerjaan").select2({
                    placeholder: "Please Select",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#status_nikah").select2({
                    placeholder: "Please Select",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#unit").select2({
                    placeholder: "Please Select",
                    theme: "bootstrap"

                });
            });

            $(document).ready(function () {
                $("#agama").select2({
                    placeholder: "Please Select",
                    theme: "bootstrap"

                });
            });
  </script>
  
<script>
var $jnoc = jQuery.noConflict();
    $jnoc(function() {
        $jnoc( "#nomor_rekam_medis" ).autocomplete({
            source: "module/transaksi_pasien/load_data.php",
            minLength: 2,
            select: function( event, ui ) {
              
    $jnoc('#nama_pasien').val(ui.item.nama_pasien);
    $jnoc('#jenis_kelamin_pasien').val(ui.item.jenis_kelamin_pasien);
    

            }
        });
    });
</script>

Silahkan login untuk menjawab!