newphpbees
18 Dec 2011, 08:06 PM
Hi
Before, I got a problem in using arrow up and down key in choosing employee name.. And now with the help of other I fixed it, but now I got an problem when I search the name of employee his data was not displayed. And also when i type in search field after I type one letter it focus/fall in the name list..it wrong..it would be the cursor will stick in the textfield while I'm typing letters.
Here is my new code:
left.tpl
<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 the javascript code:
<script>
function searchemppay(queryString) {
var ajaxRequest = remoteRequestObject();
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
var result = ajaxRequest.responseText;
document.getElementById('searchpayroll').innerHTML = result;
}
}
var url = "search.php?query=" + queryString;
ajaxRequest.open("GET", url, true);
ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
ajaxRequest.send(null);
}
function changeEmployeePay(queryID) {
window.location = "SearchData.php?queryEmpID=" + queryID;
}
</script>
search.php //where i encountered problem
<?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();
?>
and the SearchData.php
<?php
session_start();
$queryStr = trim($_GET["queryEmpID"]);
$_SESSION['empID'] = $queryStr;
session_write_close();
header("Location:DisplayEmpPayroll.php");
exit();
?>
I hope someone can help me to resolved this another issue..
But I tried also to fix it..
Thank you so much..
Before, I got a problem in using arrow up and down key in choosing employee name.. And now with the help of other I fixed it, but now I got an problem when I search the name of employee his data was not displayed. And also when i type in search field after I type one letter it focus/fall in the name list..it wrong..it would be the cursor will stick in the textfield while I'm typing letters.
Here is my new code:
left.tpl
<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 the javascript code:
<script>
function searchemppay(queryString) {
var ajaxRequest = remoteRequestObject();
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
var result = ajaxRequest.responseText;
document.getElementById('searchpayroll').innerHTML = result;
}
}
var url = "search.php?query=" + queryString;
ajaxRequest.open("GET", url, true);
ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
ajaxRequest.send(null);
}
function changeEmployeePay(queryID) {
window.location = "SearchData.php?queryEmpID=" + queryID;
}
</script>
search.php //where i encountered problem
<?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();
?>
and the SearchData.php
<?php
session_start();
$queryStr = trim($_GET["queryEmpID"]);
$_SESSION['empID'] = $queryStr;
session_write_close();
header("Location:DisplayEmpPayroll.php");
exit();
?>
I hope someone can help me to resolved this another issue..
But I tried also to fix it..
Thank you so much..