Hi There!

I have a Ajax Function copied from W3Shools

I have modified them as my Requirement but it won able to send the xmlHTTP request to my PHP page for result

here the function

function showUser(str,txtId,mth,url)

if (window.XMLHttpRequest)
  xmlhttp=new XMLHttpRequest();
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

url = url+"?str=";

The HTML Page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" src="ajax.js"></script>
<form method="GET" action="" name="myForm" id="myForm" onkeyup="showUser('this.value','txtHint','GET','d.php');">
<input type="text" name="txtStr" id="txtStr">
<span id="txtHint" name="txtHint"></span>

and the PHP page

	$str = $_GET['str'];
	echo $str;
	echo "Hello";


Is there anyone can help me please !
Thanks in Advanced


Instead of writing 'this.value' try below
Pass thetext field value not the form value

<form method="GET" action="" name="myForm" id="myForm" onkeyup="showUser(txtStr.value,'txtHint','GET','d.php');">

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.