Forum Moderators: open
<input type="text" name="title" id="textfield" onkeyup="getSuggest(event)" />
The idea is that when users type in something into the text box, the function gets called and detects a keyup event and then it calls the function that accesses the XMLHttpRequestObject and does some MySQL queries (FULLTEXT searches) and displays the results as their typing. Everything works great in IE7, but in Firefox, if you type in the textbox too quickly, getSuggest() isn't being called quick enough or it's not being called at all. I tried using onKeypress and it was the same problem. I'm not sure if in FireFox the results are taking too long to be displayed while a user types in the textbox or if it's something to do with thetext box itself. Here is relevant code:
function getSuggest(keyEvent){
keyEvent = (keyEvent) ? keyEvent : window.event;
input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;
if(keyEvent.type == "keyup"){
var targetDiv = document.getElementById("bottomContent2p32");
targetDiv.innerHTML = "<div></div>";
if(input.value){
getData('data.php', 'bottomContent2p32');
}
}
And the getData function is standard AJAX that I'm sure is correct. I know there is nothing wrong with data.php and I don't suspect its the queries taking too long because then it shouldn't be workign 100% correctly in IE. So at the moment I am stumped. Any help is appreciated.
Thanks in advance!