Jump to content

html dom events dont always work


dzhax

Recommended Posts

I am using ie9, firefox 5, and chrome to test a page.the onkeyup event is supported by all 3 browsers but it hardly ever works.I am using it with jquery.autocomplete to pull from my database what the user might be trying to type in.

<html><head><script src="lib/js/jquery-latest.js"></script><link rel="stylesheet" href="lib/css/main.css" type="text/css" /><link rel="stylesheet" href="lib/css/jquery.autocomplete.css" type="text/css" /><script type="text/javascript" src="lib/js/jquery.bgiframe.min.js"></script><script type="text/javascript" src="lib/js/jquery.autocomplete.js"></script>  <script type="text/javascript">	 function lookup(inputString, field){		  if(inputString.length > 0) {			   var url2load = 'lib/rpc.php?queryString=null&field='+field;			   $.get(url2load, function(data){					//alert(data);					var results = data.split('~!~');					$("#inputString"+field+"").autocomplete(results);			   });		  }	 }</script></head><body>	 <div>		  Event: <input id="inputStringevent" onkeydown="lookup(this.value'event');" />	 </div></body></html>

this code in order to load the autocomplete i have to type atleast 1 letter and click on the textbox like 4-5 times before the suggestion(s) show up.is there something wrong with my application of the code that is causing this?

Link to comment
Share on other sites

opps my bad I was trying some different methods and manually put the code back to what i had beforeonkeyup = "lookup(this.value,'event')"this is what that should of read.still same situation.

Link to comment
Share on other sites

i replaced lookup with an alert('MESSAGE HERE') and it does the same thing.so its not the code taking to long to load. its got the be the event simply not triggering when its supposed to.http://projects.garrett-innovations.com/csr-rank^ that's the page that i am working with. and pulled the test code from.its loading a string from the rpc.php and splits it into an array that it displays as the suggestion below the textbox.I use Cage of Chaos for my test. under the event field. I will add an alert to first name with the same onkeyup to show how it does the same thing.EDIT:It could be load time for the array. If that is the case is there a better way to implement this process. maybe finding a way to load and split the array with the onfocus event then onkeyup it just has to read the array? or onload for the whole page load each fields arrays and call them individually?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...