Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /***** index.php *****/ ?>
- <?php
- $jml=isset($_GET['jml'])?(!empty$_GET['jml']?$_GET['jml']:2):2;
- ?>
- <script language='javascript' src='ajax.js'></script>
- <form>
- <input type='hidden' name='jml' value='<?php echo $jml;?>'>
- <?php
- for($n=1;$n<=$jml;$n++)
- {
- echo "<div class='textbox'>"
- ."<input type='text' name='nim$n' placeholder='masukkan nim' id='searching$n' onkeyup='nim(this)' />"
- ."<div id='pencariannim'></div>
- ."</div>";
- }
- ?>
- </form>
- <?php /*******ajax.js*******/ ?>
- //pencarian nim
- function nim(myparam){
- var obj=myparam.nextSibling;
- var url='proses_ajax_ceknim.php?searching='+myparam.value;
- while(obj.nodeType!=1){
- obj=obj.nextSibling;
- }
- xmlhttp.open("GET", url);
- xmlhttp.onreadystatechange = function() {
- if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
- obj.innerHTML = xmlhttp.responseText;
- } else {
- obj.innerHTML = "<div align ='center'><img src='img/loading.gif' alt='Loading' />Loading...!!!</div>";
- }
- }
- xmlhttp.send(null);
- }
- <?php /**** Proses_ajax_ceknim.php ***/ ?>
- <?php
- $key=$_GET['searching'];
- $result=mysql_query("select * from tblmhs where nim like '%$key%'",$koneksi);
- $get_pages=mysql_num_rows($result);
- if ($get_pages){
- $row=mysql_fetch_array($result);
- $nim=$row['nim'];
- echo"benar";
- }
- else
- {
- echo"<br><b>Belum ada data!!</b>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement