Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. function changeLocation()
  2. {
  3. var x= document.getElementById("state");
  4. var val = x.options[x.selectedIndex].value;// value selected by user in state is assigned to variable var
  5.  
  6. var xhttp;
  7. if (window.XMLHttpRequest)
  8. { // Mozilla, Safari, ...
  9. xhttp = new XMLHttpRequest();
  10. }
  11. else if (window.ActiveXObject)
  12. { // IE 8 and older
  13. xhttp = new ActiveXObject("Microsoft.XMLHTTP");
  14. }
  15. xhttp.open("GET","localhost/location.php?t=" + val,true);//variable being sent is t
  16. xhttp.send(null);
  17.  
  18. xhttp.onreadystatechange = function()//error checking required
  19. {
  20. if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
  21. {
  22. //document.getElementById("location").value = xmlhttp.responseText;
  23. var ajaxdisp = document.getElementById("location")
  24. ajaxdisp.innerHTML = xmlhttp.responseText;//need to look through full manual for it
  25. }
  26. else
  27. {
  28. alert("needs Debugging");
  29. }
  30. }
  31. }
  32.  
  33. <?php
  34. include "logconnect.php";
  35. $t = $_REQUEST["t"];
  36. $result = $conn->query("SELECT DISTINCT location FROM office where state = '".$t."'");
  37. $disp = "<select>";
  38. while($row = $result->fetch_assoc())
  39. {
  40. $disp .= "<option>";
  41. $disp .= $row['location'];
  42. $disp .= "</option>";
  43. }
  44. $disp .= "</select>";
  45. echo $disp;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement