senior myphptutorial,, gimana cara membuat pop up pada saat insert pada textbox (kodeprimary) keluar pop up klo data sudah ada pada database,, tolong banget pencerahanny y senior,,
ini script form saya :
<?php
//Koneksi Ke Server Database
 include_once "../librari/koneksi.php";
 include_once "../librari/koneksi-auto.php";
 include_once "../librari/librari.php";
?>

<html>
<head>
	<link type="text/css" href="js/jquery-ui-themes-1.9.2/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />   
    <script type="text/javascript" src="js/jquery-183/jquery.min.1.8.3.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.9.2/ui/minified/jquery-ui.min.js"></script>

  <script type="text/javascript"> 
      $(document).ready(function(){
        $("#tanggal").datepicker({
		dateFormat  : 'yy-mm-dd',
		changeMonth : true,
		changeYear  : true					
        });
        //tambahkan auto complete
        $('#no_anggota').autocomplete({
        	source: "get_data/getdataPinjm.php",
        	minLength: 2,
        	select: function( event, ui ) {
        		$('#txtNm').val(ui.item.nama);
				$('#tanggal').val(ui.item.tglpinj);
				$('#order1').val(ui.item.jmlPinj);
				$('#harga1').val(ui.item.lmAng);
				$('#total1').val(ui.item.angpok);
				$('#total2').val(ui.item.bungpinj);
				$('#total3').val(ui.item.jumlang);
				$('#total4').val(ui.item.totpinj);
        	}
        });
      });
    </script>
	
	<script language="javascript">
function kondisi(form)
{

if(form.no_anggota.value=="")
 {
	alert("No Anggota Belum Terdaftar");
	form.no_anggota.focus();
	return(false);
	 }
if(form.txtNm.value=="")
 {
	alert("No Anggota Belum Terdaftar");
	form.no_anggota.focus();
	return(false);
	 } 
if(form.tanggal.value=="")
 {
	alert("Tanggal Peminjaman Belum Di Isi");
	form.tanggal.focus();
	return(false);
	 }
if(form.order1.value=="")
 {
	alert("Jumlah Pinjaman Belum Di isi");
	form.order1.focus();
	return(false);
}
if(form.harga1.value=="")
 {
	alert("Lama Angsuran Belum Di isi");
	form.harga1.focus();
	return(false);
}	
return(true);
}
</script>

<script>
function startCalc(){ 
interval = setInterval("calc()",1); 
} 
function calc(){ 
one1 = document.form1.order1.value; 
two1 = document.form1.harga1.value; 
three1 = document.form1.bunga1.value; 
four1 = document.form1.bunga2.value;
total1 = document.form1.total1.value;
total2 = document.form1.total2.value;


document.form1.total1.value = (one1 * 1) / (two1 * 1); 
document.form1.total2.value = (one1 * 1) * (three1 * 1); 
document.form1.total3.value = (total2 * 1) + (total1 * 1);
document.form1.total4.value = ((one1 * 1) * (four1 * 1) + (one1 * 1));


} 
function stopCalc(){ 
clearInterval(interval); 
} 
</script>
    
</head>
<body>

<form name="form1" method="post" action="PinjamanTambahSim.php" onSubmit="return kondisi(this)" enctype="multipart/form-data">
  <table width="500" border="0" cellspacing="2" cellpadding="0" class="keliling">
    <tr bgcolor="#00CCFF"> 
      <td colspan="5" bgcolor="#CCCCFF"><center><b> ENTRY DATA PINJAMAN</b></center></td>
    </tr>
	
    <tr> 
      <td width="300" align="right">Nomor Pinjaman : </td>
      <td width="300">
	   <input name="no_pinj" type="text" id="no_pinj" value="<?php echo kdauto("pinjaman","P"); ?>" disabled="disabled" />
       <input name="no_pinj" type="hidden" id="no_pinj" value="<?php echo kdauto("pinjaman","P"); ?>" />
	  </tr> 
	   

    <tr>
    <td align="right">Nomor Anggota :</td>
    <td>
    <input size="5" name="no_anggota" type="text" id="no_anggota"/> 
	</tr>
	
    <tr>
    <td align="right">Nama Anggota : </td>
     <td><input name="txtNm" type="text"  id="txtNm" readonly></td>
    </tr>

     <tr>
      <td align="right">Tanggal Pinjam : </td>
      <td><input id="tanggal" type="text" name="tanggal">
    </tr>
	
	
	 <tr>
    <td align="right">Jumlah Pinjaman : </td>
     <td><input  name="order1" type="text" id="order1" onfocus="startCalc();" onblur="stopCalc();" value="" size="25"></td>
    </tr>
	
	<tr>
    <td align="right">Lama Angsuran : </td>
     <td><input name="harga1" type="text" id="harga1" onfocus="startCalc();" onblur="stopCalc();" value="" size="5"></td>
    </tr>
	
	<tr>
    <td align="right">Angsuran Pokok : </td>
	<td><input name="total1" type="text" id="total1" size="25" readonly></td>
    </tr>
	
	<tr>
    <td align="right">Bunga Pinjaman : </td>
	<td><input name="total2" type="text" id="total2" size="25" readonly></td>
     <td><input name="bunga1" type="hidden" id="bunga1" onfocus="startCalc();" onblur="stopCalc();" value="0.01" size="5"/></td>
    </tr>
	
	<tr>
    <td align="right">jumlah Angsuran : </td>
     <td><input name="total3" type="text" id="total3" size="25" readonly></td>
    </tr>
	
	<tr>
    <td align="right">Total Pinjaman : </td>
     <td><input name="total4" type="text" id="total4" size="25" readonly></td>
	 <td><input name="bunga2" type="hidden" id="bunga2" onfocus="startCalc();" onblur="stopCalc();" value="0.1" size="5"/></td>
    </tr>
	
			
	<tr> 
      <td>&nbsp;</td>
      <td><input name="TbSimpan" type="submit" value="Tambah">
      <input name="reset" type="reset" value="Cancel"></td>
    </tr>
  </table>
  <br></br>
  
<?php
  include_once "../librari/koneksi.php";
  include_once "../librari/librari.php";
?>

<div style="border:1px solid rgb(238,238,238);padding:10px;overflow:auto;width:560px;height:autopx;">
<table width="700" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
  <tr> 
    <td colspan="13" bgcolor="#CCCCFF"><center><b>DAFTAR PINJAMAN SELURUH ANGGOTA</b></center></td>
  </tr>
  <tr> 
    <td width="15" align="center" bgcolor="#00FFCC"><b>No.</b></td>
    <td width="47" align="center" bgcolor="#00FFCC"><b>No Pinjam</b></td>
    <td width="143" align="center" bgcolor="#00FFCC"><b>No Anggota</b></td>
	<td width="143" align="center" bgcolor="#00FFCC"><b>Nm Anggota</b></td>
    <td width="200" align="center" bgcolor="#00FFCC"><b>Tgl Pinjam</b></td>
	<td width="143" align="center" bgcolor="#00FFCC"><b>Jml Pinjam</b></td>
	<td width="90" align="center" bgcolor="#00FFCC"><b>Lama Angsuran</b></td>
	<td width="90" align="center" bgcolor="#00FFCC"><b>Angs Pokok</b></td>
	<td width="90" align="center" bgcolor="#00FFCC"><b>Bunga Pinjam</b></td>
	<td width="140" align="center" bgcolor="#00FFCC"><b>Jumlah Angs</b></td>
	<td width="140" align="center" bgcolor="#00FFCC"><b>Total Pinjaman</b></td>
		<td width="140" align="center" bgcolor="#00FFCC"><b>Sisa Hutang</b></td>
		<td width="140" align="center" bgcolor="#00FFCC"><b>Status</b></td>	
  </tr>
  

  
<?php
  $koneksi = koneksi_db();
  $sql = "SELECT p.no_pinjam,p.tgl_pinjam,p.jml_pinjam,p.lm_ang,p.pokok_angs,p.bunga_pinjam,p.jml_angsuran,p.total_pinjaman,p.status,anggota.no_anggota,nm_anggota,MIN(angsuran.sisa_hutang)
       FROM pinjaman p LEFT JOIN anggota ON anggota.no_anggota=p.no_anggota LEFT JOIN angsuran ON p.no_pinjam=angsuran.no_pinjam group by no_pinjam";
  $qry = mysql_query($sql,$koneksi);
  while ($data = mysql_fetch_array($qry)) 
  {
  	$no++;
	//operator mencari jumlah keseluruhan simpanan
	$tot_keseluruhan= $tot_keseluruhan1 + $data[total_pinjaman];
?>
  <tr bgcolor="#FFFFFF"> 
    <td><?php echo $no;?></td> 
    <td><?php echo $data['no_pinjam']; ?></td>
    <td><?php echo $data['no_anggota']; ?></td>
	<td><?php echo $data['nm_anggota']; ?></td>
	<td><?php echo $data['tgl_pinjam']; ?></td>
	<td><?php echo $data['jml_pinjam']; ?></td>
	<td><?php echo $data['lm_ang']; ?></td>
	<td><?php echo $data['pokok_angs']; ?></td>
	<td><?php echo $data['bunga_pinjam']; ?></td>
	<td><?php echo $data['jml_angsuran']; ?></td>
	<td><?php echo $data['total_pinjaman']; ?></td>
	<td><?php echo $data['MIN(angsuran.sisa_hutang)']; ?></td>
	<td><?php echo $data['status'];?></td>
  </tr>
  <?php
  }
  
  ?>
  
  <tr>
	<th colspan="10" align="center">Total Pinjaman Keseluruhan</th>

  	<td bgcolor="#FPCCKF">Rp.<?php echo $tot_keseluruhan ?> </td>
	</tr>
</table>
</div>
</form>
</body>
</html>

   
  
  <br></br>
  
  <br>
  <tr>
  <td>Ket :</td>
  </tr>
  </br>
  
  <br>
  <td>*) Bunga Perbulan = 1%</td>
  </br>
  
<br>
 <tr>
  <td>*) Lama Angsuran Yang Ditetapkan yaitu 10 Kali Angsuran</td>
  </tr>
  </br>

 

Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Dec 20, 2012 · 0 Suka · 0 Tidak Suka
pertama buat file cek-sisa-hutang.php:
<?php
  include_once "../librari/koneksi.php";
  include_once "../librari/librari.php";
  $id = $_GET['id'];
  $koneksi = koneksi_db();
  $sql = "SELECT MIN(angsuran.sisa_hutang) as sisaHutang
       FROM pinjaman p LEFT JOIN anggota ON anggota.no_anggota=p.no_anggota LEFT JOIN angsuran ON p.no_pinjam=angsuran.no_pinjam 
       where anggota.no_anggota='$id' group by no_pinjam";
  $qry = mysql_query($sql,$koneksi);
  $allow = true;
  if(mysql_num_rows($qry)){
  	$data = mysql_fetch_array($qry);
  	if($data['sisaHutang'] > 0){
  		$allow = false;
  	}
  }
  echo json_encode(array('allow' => $allow));
  

kemudian ubah javascript dibagian autocomplete
<script type="text/javascript"> 
      $(document).ready(function(){
        $("#tanggal").datepicker({
		dateFormat  : 'yy-mm-dd',
		changeMonth : true,
		changeYear  : true					
        });
        //tambahkan auto complete
        $('#no_anggota').autocomplete({
        	source: "get_data/getdataPinjm.php",
        	minLength: 2,
        	select: function( event, ui ) {
        		cekSisaHutang(ui.item.value);
        		$('#txtNm').val(ui.item.nama);
				$('#tanggal').val(ui.item.tglpinj);
				$('#order1').val(ui.item.jmlPinj);
				$('#harga1').val(ui.item.lmAng);
				$('#total1').val(ui.item.angpok);
				$('#total2').val(ui.item.bungpinj);
				$('#total3').val(ui.item.jumlang);
				$('#total4').val(ui.item.totpinj);
        	}
        });
      });
      function cekSisaHutang(id){
      	$.ajax({
      		url:'cek-sisa-hutang.php?id='+id,
      		dataType:'json',
      		success:function(resp){
      			if(!resp.allow){
      				alert('Anggota masih memiliki pinjaman aktif');
      			}
      		},
      		error:function(){
      			alert('terjadi kesalahan saat mengecek sisa hutang');
      		}
      	});
      }
</script>
0
Loading...
bujank_chicken · Dec 20, 2012 · 0 Suka · 0 Tidak Suka
thanx mas Ellyx,,,
udah saya laksanakan nd jalan mas , , ,
skali lagi thanx y mas . . .