dzhax Posted August 14, 2011 Share Posted August 14, 2011 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 More sharing options...
chrici Posted August 14, 2011 Share Posted August 14, 2011 You say that you are using the onkeyup event but in the code you are using the onkeydown event. Change that to onkeyup and I think it will work. Link to comment Share on other sites More sharing options...
jeffman Posted August 14, 2011 Share Posted August 14, 2011 This looks weird: lookup(this.value'event') Link to comment Share on other sites More sharing options...
dzhax Posted August 14, 2011 Author Share Posted August 14, 2011 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 More sharing options...
justsomeguy Posted August 15, 2011 Share Posted August 15, 2011 Have you checked to see if the functions aren't executing, or if the request is just taking a while to come back? Link to comment Share on other sites More sharing options...
dzhax Posted August 15, 2011 Author Share Posted August 15, 2011 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 More sharing options...
justsomeguy Posted August 15, 2011 Share Posted August 15, 2011 The event is always triggering, it's always sending out a request. I'm not sure why it doesn't show the list, that's probably in the autocomplete method somewhere. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.