I am trying to make this.
- Suggest name in select menu as typed in text box
- Once the preferred name is clicked in the menu then show that users profile in other form (currently div would be ok).
Part 1 works good. But part 2 doesnot show any change. below are the codes.
<select name="names" id ="names" onchange="getdata();">
<?php
while ($row = mysql_fetch_array ($result)) {
?>
<option id="names1" onchange="getdata()" value="<?php echo $row['name'];?>">
<?php
echo $row['name'];
?>
</option>
<?php
$str = "";
$i++;
}
?>
</select><div id="ajaxDiv1">
<?php include("find-name.php"); ?></div>
the getdata() is in javascript file which has code like
function getdata()
{
var req = getXMLHTTP();
if (req)
{
//function to be called when state is changed
req.onreadystatechange = function()
{
//when state is completed i.e 4
if (req.readyState == 4)
{
var ajaxSearchResults1 = document.getElementById("ajaxDiv1");
ajaxSearchResults1.innerHTML = req.responseText;
// only if http status is "OK"
if (req.status == 200)
{
var new1 = document.getElementById('names').value;
var queryString1 = "?names=" + new1;
}
else
{
alert("There was a problem while using XMLHTTP:
" + req.statusText);
}
}
}
req.open("GET", "find-name.php" + querystring1, true);
req.send(null);
}
}
and in the find-name.php i am for now only displaying the value recieved.
$names=$_GET['names'];
echo $names;
Where am i doing wrong Please help asap