I am developing a social website like facebook in php. I have a search bar in a page named as showdetails.php
which should display the name of the users (in the database) in a dropdown list like div which can be clicked for selection
,as user types the letters in the search box.I have done this using ajax.When I click a particular user name in the dropdown list, it automatically comes to the search box.My issue is that there is another div which needs to display the details of the selected user clicked by the user.I have searched a lot but couldnt get the correct one.I am unaware of returning two different values from a ajax call since in my knowledge var response = xmlhttp.responseText;
,the variable response can store only one result.
My searchvalues.php
which contains the code of searching the username
$hint = "<table>";
while($row = mysql_fetch_array($result_query_get_following))
{
$act_fname = $row['acnt_fname'];
$act_lname = $row['acnt_lname'];
$act_name = $act_fname . ' ' . $act_lname;
$hint.= "<tr onClick='showVal(\"".$act_name."\");'><td >".$act_name."</td></tr>";
$following_id = $row['flwing_following_user_id'];
$following_member_class = $row['acnt_member_class'];
$following_profile_picture = $row['acnt_profile_picture'];
}
$hint .= "</table>";
}
if ($hint == "")
{
$response="no suggestion";
}
else
{
$response=$hint;
}
//output the response
echo $response;
My javascript functions in showdetails.php
function showVal(val)
{
document.getElementById("quicksearch").value=val;
document.getElementById("search").style.display="none";
}