Simpan dalam dpl_data.php
<form method="POST" action="dkkn_tambah_simpan.php">
<tbody>
<tr> <input type="text" value="<?php echo $_GET['angkatan']; ?>" id="angkatan" name="angkatan" /></tr>
<tr><td>Nama DPL</td><td>:
<select name="nama" id="nama">
<option value="">- Pilih Nama Dosen -</option>
<!-- looping data nama -->
<?php
$sql_dosen="select * from tbdos";
$q=$mysqli->query($sql_dosen);
while($row_dosen=mysqli_fetch_array($q)){
?>
<option value="<?php echo $row_dosen["nip"] ?>"><?php echo $row_dosen["nip"] ." - " . $row_dosen["nama"] ?></option>
<?php
}
?>
</select>
<img src="loader.gif" width="10px" height="10px" id="imgLoad" style="display:none">
<br>
<tr><td>NIK Dosen</td><td>:
<select name="kota" id="kota">
<!-- hasil data dari cari_dosen.php akan ditampilkan disini ----------------------------------------------->
</select>
<tr><td>Type KKN</td><td>:
<select id="jenis" name ="jenis" />
<option value="Reguler 1" placeholder="Reguler I">Reguler 1
<option value="Reguler 2" placeholder="Reguler I">Reguler 2
<option value="Tematik" placeholder="Reguler I">Tematik
<img src="loader.gif" width="10px" height="10px" id="imgLoad" style="display:none">
</select>
</td></tr>
<tr><td>Tahun Akademik</td><td>:
<select id="tahun_akademik" name ="tahun_akademik" />
<?php include ("menu/listtakalender.php"); ?>
</select>
</td></tr>
<tr><td>Semester</td><td>:
<select id="semester" name ="semester" />
<option placeholder="Pilih Semester">- Pilih Semester Ganjil/Genap
<option value="1" placeholder="">Ganjil
<option value="2" placeholder="">Genap
<option value="2" placeholder="">Antar Waktu
</select>
</td></tr>
</tbody>
</table>
<button type="submit" id="submit" class="btn btn-small btn-warning" ><a href="javascript:void(0)"></a><i class="icon-upload"></i> Simpan</button>
</form>
=============
Paling bawah ditambah script:
<script>
$("#nama").change(function(){
// variabel dari nilai combo box nama
var nik = $("#nama").val();
// tampilkan image load
$("#imgLoad").show("");
// mengirim dan mengambil data
$.ajax({
type: "POST",
dataType: "html",
url: "menu/cari_dosen.php",
data: "prov="+nik,
success: function(msg){
// jika tidak ada data
if(msg == ''){
alert('Tidak ada data Dose ');
}
// jika dapat mengambil data,, tampilkan di combo box kota
else{
$("#kota").html(msg);
}
// hilangkan image load
$("#imgLoad").hide();
}
});
});
</script>
Simpan dalam menu/cari_dosen.php
<?php
// server info
$server = 'localhost';
$user = 'root';
$pass = '';
$db = 'simpeg';
// connect to the database
$mysqli = new mysqli($server, $user, $pass, $db);
// show errors (remove this line if on a live site)
mysqli_report(MYSQLI_REPORT_ERROR);
?>
<?php
$sql_dosen1="select * from tbdos where nip='".$_POST["prov"]."'";
$q=$mysqli->query($sql_dosen1);
while($row_dosen1=mysqli_fetch_array($q)){
?>
<option value="<?php echo $row_dosen1["nip"] ?>"><?php echo $row_dosen1["nip"] ?></option><br>
<?php
}
?>
<form method="POST" action="dkkn_tambah_simpan.php">
<tbody>
<tr> <input type="text" value="<?php echo $_GET['angkatan']; ?>" id="angkatan" name="angkatan" /></tr>
<tr><td>Nama DPL</td><td>:
<select name="nama" id="nama">
<option value="">- Pilih Nama Dosen -</option>
<!-- looping data nama -->
<?php
$sql_dosen="select * from tbdos";
$q=$mysqli->query($sql_dosen);
while($row_dosen=mysqli_fetch_array($q)){
?>
<option value="<?php echo $row_dosen["nip"] ?>"><?php echo $row_dosen["nip"] ." - " . $row_dosen["nama"] ?></option>
<?php
}
?>
</select>
<img src="loader.gif" width="10px" height="10px" id="imgLoad" style="display:none">
<br>
<tr><td>NIK Dosen</td><td>:
<select name="kota" id="kota">
<!-- hasil data dari cari_dosen.php akan ditampilkan disini ----------------------------------------------->
</select>
<tr><td>Type KKN</td><td>:
<select id="jenis" name ="jenis" />
<option value="Reguler 1" placeholder="Reguler I">Reguler 1
<option value="Reguler 2" placeholder="Reguler I">Reguler 2
<option value="Tematik" placeholder="Reguler I">Tematik
<img src="loader.gif" width="10px" height="10px" id="imgLoad" style="display:none">
</select>
</td></tr>
<tr><td>Tahun Akademik</td><td>:
<select id="tahun_akademik" name ="tahun_akademik" />
<?php include ("menu/listtakalender.php"); ?>
</select>
</td></tr>
<tr><td>Semester</td><td>:
<select id="semester" name ="semester" />
<option placeholder="Pilih Semester">- Pilih Semester Ganjil/Genap
<option value="1" placeholder="">Ganjil
<option value="2" placeholder="">Genap
<option value="2" placeholder="">Antar Waktu
</select>
</td></tr>
</tbody>
</table>
<button type="submit" id="submit" class="btn btn-small btn-warning" ><a href="javascript:void(0)"></a><i class="icon-upload"></i> Simpan</button>
</form>
=============
Paling bawah ditambah script:
<script>
$("#nama").change(function(){
// variabel dari nilai combo box nama
var nik = $("#nama").val();
// tampilkan image load
$("#imgLoad").show("");
// mengirim dan mengambil data
$.ajax({
type: "POST",
dataType: "html",
url: "menu/cari_dosen.php",
data: "prov="+nik,
success: function(msg){
// jika tidak ada data
if(msg == ''){
alert('Tidak ada data Dose ');
}
// jika dapat mengambil data,, tampilkan di combo box kota
else{
$("#kota").html(msg);
}
// hilangkan image load
$("#imgLoad").hide();
}
});
});
</script>
Simpan dalam menu/cari_dosen.php
<?php
// server info
$server = 'localhost';
$user = 'root';
$pass = '';
$db = 'simpeg';
// connect to the database
$mysqli = new mysqli($server, $user, $pass, $db);
// show errors (remove this line if on a live site)
mysqli_report(MYSQLI_REPORT_ERROR);
?>
<?php
$sql_dosen1="select * from tbdos where nip='".$_POST["prov"]."'";
$q=$mysqli->query($sql_dosen1);
while($row_dosen1=mysqli_fetch_array($q)){
?>
<option value="<?php echo $row_dosen1["nip"] ?>"><?php echo $row_dosen1["nip"] ?></option><br>
<?php
}
?>
Comments
Post a Comment