newphpbees
19 Dec 2011, 01:48 AM
Hi...
i got problem in using this 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 == 40) {
// up pressed
if (i < links.length - 1) i++;
}
else if (key == 38) {
// down pressed
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>
the problem is...when I type in search textfield it focus in the name list..like for example i type a after I press a it was focus in the firstname, which is wrong..
I think it cause from the javascript code..
I want to happen is i continue typing in search textfield.
Thank you
i got problem in using this 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 == 40) {
// up pressed
if (i < links.length - 1) i++;
}
else if (key == 38) {
// down pressed
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>
the problem is...when I type in search textfield it focus in the name list..like for example i type a after I press a it was focus in the firstname, which is wrong..
I think it cause from the javascript code..
I want to happen is i continue typing in search textfield.
Thank you