Hi...
I already solved the issue in displaying the employee name.
This is my revised code:
Code:
<script>
window.onload = function() {
var ul = document.getElementById('searchpayroll');
var links = ul.getElementsByTagName('a');
var i = 0;
document.onkeyup = function(e){
e = window.event || e;
var key = e.charCode || e.keyCode;
//if (key == 38) {
if (key == 40) {
// up pressed
//if (i < links.length - 1) i++;
if (i < links.length - 1) i++;
}
else if (key == 38) {
// down pressed
if (i > 0) i--;
// if (i < 0) i++;
}
// focus on link
links[i].focus();
// request content in here for link with ajax
// alert(links[i].href);
}
}
</script>
<div id="Search">
<form>
<p class="serif"><b>Search Lastname:</b></p>
<input type="text" name="search_" size="20" onkeyup="searchemppay(this.value);">
<!--<div id="searchpayroll" style="overflow:auto; height:390px; width:auto; margin-left:2px" >-->
<hr />
<ul id="searchpayroll" style="overflow:auto; height:385px; width:auto; margin-left:2px;">
<!--<ul>-->
{section name=co_emp loop=$personalAll}
<!--<li onclick="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li> -->
<li><a href="SearchData.php?queryEmpID={$personalAll[co_emp].EMP_ID}">{$personalAll[co_emp].FULLNAME}</a></li>
<hr />
{sectionelse}
<li>No records found</li>
{/section}
</ul>
</div>
</div>
and now I encountered error in displaying employee name and displaying data when the name was search first.
here is the original code for search:
Code:
<?php
session_start();
include 'config.php';
$queryString = $_GET["query"];
if ($queryString == "" || $queryString == null) {
$sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL
ORDER BY FULLNAME ASC";
}
else {
$sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE LNAME LIKE '" . $queryString . "%' ORDER BY FULLNAME ASC";
}
$recPersonalQuery = $conn->Execute($sql);
if (!$recPersonalQuery->BOF) {
$recPersonalQuery->MoveFirst();
}
echo "<hr />";
echo "<ul>";
while (!$recPersonalQuery->EOF) {
$empID = $recPersonalQuery->fields["EMP_ID"];
$empFullName = $recPersonalQuery->fields["FULLNAME"];
echo "<li onclick=changeEmployeePay('$empID'); style= 'font-family:'Times New Roman',Times,serif; font-size:10%;'>$empFullName</li>";
echo "<hr />";
$recPersonalQuery->MoveNext();
}
echo "</ul>";
$recPersonalQuery->Close();
exit();
?>
and now i revised it to work the up and down key:
Code:
<?php
session_start();
include 'config.php';
$queryString = $_GET["query"];
$queryStr = trim($_GET["queryEmpID"]);
$_SESSION['empID'] = $queryStr;
if ($queryString == "" || $queryString == null) {
$sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL
ORDER BY FULLNAME ASC";
}
else {
$sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE LNAME LIKE '" . $queryString . "%' ORDER BY FULLNAME ASC";
}
$recPersonalQuery = $conn->Execute($sql);
if (!$recPersonalQuery->BOF) {
$recPersonalQuery->MoveFirst();
}
echo "<hr />";
echo "<ul>";
while (!$recPersonalQuery->EOF) {
$empID = $recPersonalQuery->fields["EMP_ID"];
$empFullName = $recPersonalQuery->fields["FULLNAME"];
echo "<a href='SearchData.php?queryEmpID=('$empID')'; style= 'font-family:'Times New Roman',Times,serif; font-size:10%;'>$empFullName</li>";
echo "<hr />";
$recPersonalQuery->MoveNext();
}
echo "</ul>";
$recPersonalQuery->Close();
exit();
?>
but the output is when I type one letter it was down in name list..the focus was go to name list. and also when I choose name his data was not displayed.
Thank you so much...
I also tried to figured out..
Thank you again
Bookmarks