Ok, well 2 things that you need to try for me. We are going to do some error checking.
On your php page that gets called, instead of
$q = $_GET['q'];
Try puutting a number in its place and run the page by its self.
$q = "1";
If that works, then we will move on to the javascript. If not, then redo your query statement and re run the statement with the same code from above.
/* Old */
$sql="SELECT * FROM table WHERE id = '".$q."'";
/* New */
$sql="SELECT * FROM table WHERE id = '$q'";
Now the javascript.
//try putting in an alert in the beginning.
<script type="text/javascript">
function showUser(str) {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
// Alert
alert(str);
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) (
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
if the string doesnt get passed, try this.
//try putting in an alert in the beginning.
<script type="text/javascript">
function showUser() {
var xmlhttp; // You forgot to add this.
var1 = document.getElementById("users").value;
alert(var1);
if(var1==""){
document.getElementById("txtHint").innerHTML = "";
return false;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) (
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
Make sure you add the id="users" to your select.
<select name="users" id="users" onchange="showUser()">
I know this is alot, but i want you to try this and let me know. Its just kinda funny that you dont get anything when you use php for your options, you get nothing, but html shows results.