Hi,
I need simple help. I just want to retrieve the input value $q that is passed from javascript to php.
But XMLHTTP.responseText return the both input value + whole html ? Please help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Singapore Godown</title>
</head>
<body >
<script>
function showHint(str) {
if (str.length==0) {
document.getElementById("txtHint").innerHTML="";
return;
}
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","test.php?q="+str,true);
xmlhttp.send();
}
</script>
<table>
<input type="text" onkeyup="showHint(this.value)">
<div id="txtHint"></div>
</table>
<?php
// get the q parameter from URL
$q=$_REQUEST["q"];
echo "Input: ".$q;
?>
</body>
</html>
Regards,
Halim