Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function changeLocation()
- {
- var x= document.getElementById("state");
- var val = x.options[x.selectedIndex].value;// value selected by user in state is assigned to variable var
- var xhttp;
- if (window.XMLHttpRequest)
- { // Mozilla, Safari, ...
- xhttp = new XMLHttpRequest();
- }
- else if (window.ActiveXObject)
- { // IE 8 and older
- xhttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- xhttp.open("GET","localhost/location.php?t=" + val,true);//variable being sent is t
- xhttp.send(null);
- xhttp.onreadystatechange = function()//error checking required
- {
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
- {
- //document.getElementById("location").value = xmlhttp.responseText;
- var ajaxdisp = document.getElementById("location")
- ajaxdisp.innerHTML = xmlhttp.responseText;//need to look through full manual for it
- }
- else
- {
- alert("needs Debugging");
- }
- }
- }
- <?php
- include "logconnect.php";
- $t = $_REQUEST["t"];
- $result = $conn->query("SELECT DISTINCT location FROM office where state = '".$t."'");
- $disp = "<select>";
- while($row = $result->fetch_assoc())
- {
- $disp .= "<option>";
- $disp .= $row['location'];
- $disp .= "</option>";
- }
- $disp .= "</select>";
- echo $disp;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement