textbox to search for employees
<div id="searchform">
<div id = "courses">
<form id="searchempform" name="searchempform" method="post" "/>
<li> SEARCH <b>EMPLOYEES</b> <input type="text" name="searchemployees" class="textbox" [B]onkeyup="searchemp();[/B]" /> </li>
</form>
</div>
=======================================================
typed characters sent ... ajax call to another page look out for data
<script type="text/javascript">
function [B]searchemp()[/B]
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("results").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open('GET','employeeajax.php?searchemployees='+document.searchempform.searchemployees.value,true);
xmlhttp.send();
}
</script>
-----------------------------------------------------
using the sent characters .. searching the information using sql query
<?php
include("sql2.php");
$searchemp = $_GET['searchemployees'];
if(!empty($searchemp))
{
$sql="SELECT `empid`, `Rank`, `Name`, `serviceno` FROM `frsemployees` WHERE `Name` LIKE '".mysql_real_escape_string($searchemp)."%'";
$result = mysql_query("$sql") or die ("could not connebbbbct to database");
echo'<select name="listbox" class="listbox" size="28" onclick = "[B]getinfo2(this.value);[/B] " >';
while($row=mysql_fetch_array($result))
{
$empid = $row[0];
$rank = $row[1];
$name = $row[2];
$Serviceno = $row[3];
echo"<option value='$empid' class='b'> $Serviceno $rank $name </option>";
}
echo '</select>';
}
?>
--------------------------------------------------------------
using the selected id again populating for another information
<script type="text/javascript">
function [B]getinfo2(employeeinformation)[/B]
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("employeeinformation").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","employeedetailsajax.php?id="+employeeinformation,true);
xmlhttp.send();
}
</script>
-----------------------------------------
look out for data using the clicked employees id
<?php
include("sql2.php");
$employeeserviceno = $_GET["id"];
$sql1= "SELECT frsemployees.photo, frsemployees.serviceno, frsemployees.Rank, frsemployees.Name
FROM frsemployees WHERE frsemployees.empid = '$employeeserviceno' ";
$result1 = mysql_query("$sql1") or die ("could not connebbbbct to database");
while($row=mysql_fetch_array($result1))
{
$empid = $row[0];
$rank = $row[1];
$name = $row[2];
$Serviceno = $row[3];
echo'<tr>';
echo' <td width="122" rowspan="3"><center><img src=../img/5247.PNG height=140 width = 120 border="1" style="padding:3px;"></center> </td>';
echo"<td>SN: $rank </td>";
echo'</tr>';
echo'<tr>';
echo"<td width=235>Rank:$name</td>";
echo'</tr>';
echo'<tr>';
echo"<td >SNumber:$Serviceno</td>";
echo'</tr>';
}
?>
</table>
------------------------------------------------------------------------
<div id="results">
</div>
<div id="employeeinformation">
</div>
<div id="coursesinf">
</div>
--------------------------------------
using [B]getinfo2(this.value);[/B]
i want to populated a new result to a new div
for instance the result div is populated with the employees personal information, when clicked to his id..how can i click to his same id and populated his courses information to "coursesinfdiv"