<?php
 session_start();
?>
 
<html>
<head>
<script>
function showHint(str) {
    if (str.length == 0) {
        document.getElementById("txtHint2").innerHTML = "";
		document.getElementById("txtHint").value = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
               
			  // document.getElementById("txtHint2").innerHTML = this.responseText;
			//	document.getElementById("txtHint").value = this.responseText;
				document.getElementById("msg").value = this.responseText;
            
			//var my_val=this.responseText;
			var my_val=this.responseText.split("\n")
			document.getElementById("txtHint").value = my_val[1];
			}
        };
		var params="q="+str+"&msg=aa";
        xmlhttp.open("GET", "readRecord.php?" + params, true);
        xmlhttp.send();
	   
	  
	}
	
}
</script>
</head>
<body>

<p><b>Start typing a name in the input field below:</b></p>
<form>
First name: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Suggestions: <span id="txtHint2"></span></p>
<input type="text" id="txtHint" value="txtHint">
<textarea   id="msg" style="font-size:1.1em; min-height:250px; width:500px;" value="msg">
</body>
</html>