milo3169
Programmer
- May 2, 2007
- 42
Hello everyone,
I am working on a AJAX autocomplete script and the autocomplete is working, but I would like to add some more functionality to by adding navigation through the list with the UP and DOWN arrow keys. I seem to have the javascript working where when I press down one of the arrow keys it seems to change the className, but it immediately will change the className back to the original className. Would anybody be able to tell me why this is happening? What am I doing wrong?
I know that the function "setHighlightSelection" is very basic, but it's being used for testing purposes.
Thank you in advance.
milamsteve
I am working on a AJAX autocomplete script and the autocomplete is working, but I would like to add some more functionality to by adding navigation through the list with the UP and DOWN arrow keys. I seem to have the javascript working where when I press down one of the arrow keys it seems to change the className, but it immediately will change the className back to the original className. Would anybody be able to tell me why this is happening? What am I doing wrong?
Code:
document.onkeypress = KeyCheck;
var HighlightSelection = -1;
function KeyCheck(e){
var KeyID = (window.event) ? event.keyCode : e.keyCode;
switch(KeyID){
case 38:
HighlightSelection--;
setHighlightSelection(HighlightSelection);
break;
case 40:
HighlightSelection++;
setHighlightSelection(HighlightSelection);
break;
}
}
function setHighlightSelection(num){
document.getElementById(num).className = "suggest_link_over";
}
Thank you in advance.
milamsteve