Tolong gan apa ada yang salah ? kenapa pas diklik combobox kecamatan, kelurahannya ga muncul ? scriptnya masih salahkah ? terima kasih gan.

<?php
include "../koneksi.php";

?>


<html>

<title>Input Hak Akses Lampid</title>
<link rel="stylesheet" href="../boostrap/css/bootstrap.min.css">

<script src="../js/jquery-2.1.3.min.js" type="text/javascript"></script>
</head>

<body>


<form name="form1" method="post" action="pet_simpan.php">
<div align="center">Data Hak Akses Lampid </div>
  <table width="495" border="0" align="center">

    <tr>
      <td width="131"><div align="left">Nama Petugas </div></td>
      <td width="12">:</td>
      <td width="338"><label>
        <input name="nama_petugas" type="text" id="nama_petugas" maxlength="30" size="30"/>
      </label></td>
    </tr>
    <tr>
      <td>NIP</td>
      <td>:</td>
      <td><label>
        <input name="nip" type="text" id="nip" maxlength="18" size="30"/>
      </label></td>
    </tr>
    <tr>
      <td>Status</td>
      <td>:</td>
      <td><label>
        <select name="status" >
          <option selected>--- Pilih Status ---</option>
		  <option value="1"> Adb Dinas </option>
		  <option value="2">Kepala Kasi E-Monev</option>
          <option value="3">Registrasi Kecamatan</option>
          <option value="4">Registrasi Kelurahan</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td>Kecamatan</td>
      <td>:</td>
      <td><label>
      <select name="id_kec" id="id_kec">
        <option>--- Pilih Kecamatan ---</option>
		<?php
		  include ('../koneksi.php');
		  $sql=mysql_query ("select * from kecamatan order by id_kec asc");
		  		  while ($row=mysql_fetch_assoc($sql)){
		  echo"<option value='$row[id_kec]'> $row[nama_kec]</option>";
		  
		  }
		  ?>
      </select>
      </label></td>
    </tr>
	
    <tr>
      <td>Kelurahan</td>
      <td>:</td>
      <td><label>
      <select id="id_kel"  name="id_kel">
	  <option> -Pilih Kelurahan-</option>
        <script type="text/javascript">
	  $(document).ready(function() {
		  $("#id_kec").change(function(){
			  var nama_kec=$("#id_kec").val();
			  $.ajax({
				  url:"cek_kel.php",
				  data:"id_kec="+id_kec,
				  success: function(data){
					  $("#id_kel").html(data);
				  }
			  });
		  });
    });
	</script>
    </select>
   
	  
      </label></td>
    </tr>
    <tr>
      <td>Username</td>
      <td>:</td>
      <td><label>
        <input name="username" type="text" id="username" maxlength="20" size="30">
      </label></td>
    </tr>
    <tr>
      <td>Password</td>
      <td>&nbsp;</td>
      <td><input type="password" name="password"  size="30"></td>
    </tr>
    <tr>
      <td colspan="3"><label>
        <div align="center">
          <input type="submit" name="Submit" value="Simpan">
          <input type="reset" name="Submit2" value="Batal">
          </div>
      </label></td>
    </tr>
  </table>
</form>
<script type="text/javascript" src="../boostrap/js/bootstrap.min.js"></script>


</html>

<?php
		  include ("../koneksi.php");
		  $id_kel=$_GET['id_kel'];
		  $sqllagi=mysql_query("SELECT * FROM kelurahan id_kel='$id_kel'");
		  echo "<option> - Pilih Kelurahan - </option>";
		  while ($row=mysql_fetch_assoc($sqllagi)){
		   echo"<option value='$row[id_kel]'> $row[nama_kel]</option>";
		  }
		  
		  ?>
      
Silahkan login untuk menjawab!
0
Loading...
aaron49 · Jan 1, 2016 · 0 Suka · 0 Tidak Suka
silahkan dipelajari script nya teh mungkin bisa membantu kasusnya hampir sama ko :)
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("klinik");
$result = mysql_query("select * from tbl_pemeriksaan");  
$jsArray = "var prdName = new Array();\n";  

echo '<center>Noreg:<select name="prdId" onchange="changeValue(this.value)">';     
            
            echo '<option>-------</option>';  
while ($row = mysql_fetch_array($result)) {  
    echo '<option value="' . $row['no_pemeriksaan'] . '">' . $row['no_pemeriksaan'] . '</option>';  
    $jsArray .= "prdName['" . $row['no_pemeriksaan'] . "'] = {name:'" . addslashes($row['tgl_pemeriksaan']) . "',anam:'".addslashes($row['anamnesa'])."',dial:'".addslashes($row['diagnosa'])."',peny:'".addslashes($row['nama_penyakit'])."'};\n";  
}  
echo '</select>';  


?>
<br>
<br>
Tgl Periksa:     <input type="text" name="prod_name" id="prd_name"readonly/>  
<br>
<br>
Anamnesa:        <input type="text" name="prod_anam" id="prd_anam"readonly/>  
<br>
<br>
Diagnosa:        <input type="text" name="prod_dial" id="prd_dial"readonly/>  
<br>
<br>
Penyakit:        <input type="text" name="prod_peny" id="prd_peny"readonly/>  

<script type="text/javascript">  
<?php echo $jsArray; ?>  
function changeValue(id){  
document.getElementById('prd_name').value = prdName[id].name;  
document.getElementById('prd_anam').value = prdName[id].anam;  
document.getElementById('prd_dial').value = prdName[id].dial;  
document.getElementById('prd_peny').value = prdName[id].peny;  
};    
</script>