Advertisement
freddy0512

ajax

Oct 29th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function showCustomer(str)
  6. {
  7. var xmlhttp;
  8. if (str=="")
  9. {
  10. document.getElementById("txtHint").innerHTML="";
  11. return;
  12. }
  13. if (window.XMLHttpRequest)
  14. {// code for IE7+, Firefox, Chrome, Opera, Safari
  15. xmlhttp=new XMLHttpRequest();
  16. }
  17. else
  18. {// code for IE6, IE5
  19. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  20. }
  21. xmlhttp.onreadystatechange=function()
  22. {
  23. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  24. {
  25. document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
  26. }
  27. }
  28. xmlhttp.open("GET","getcustomer.php?q="+str,true);
  29. xmlhttp.send();
  30. }
  31. </script>
  32. </head>
  33. <body> <form action="">
  34.  
  35.  
  36.  
  37. <?php
  38. include "koneksi.inc.php";
  39. $sql=mysql_query("SELECT * FROM `customer` ") or die('Error, query failed. ' . mysql_error());
  40. while ($data=mysql_fetch_array($sql))
  41. {?>
  42. <li><a href="#?id=<?php echo $data['CS_ID'];?>" onChange="showCustomer(this.value)" ><?php echo $data['CS_ID'];?></a></li>
  43. <?php } ?>
  44.  
  45.  
  46. </form>
  47. <br>
  48. <div id="txtHint">Customer info will be listed here...</div> </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement