Autocomplete with virtual keyboard

Discussion in 'JavaScript' started by baris22, Feb 2, 2011.

  1. #1
    Hello all,

    I am trying to use autocomplete with virtual keyboard (from http://keith-wood.name/keypad.html)

    I have got a small problem now. say the word is 12345 and when i type 1 auto complete comes for 0.5 seconds and goes away. when i type 2 same thing happens. When i press the back button on virtual keyboard and type 2 again auto complete comes back and stays there. What do you think is wrong?

    
    
    <script type="text/javascript" src="keyboard/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="keyboard/jquery.keypad.js"></script>
    <script type="text/javascript">
    $(function () {
     $('#inputString').keypad({
      onKeypress: function() {
       lookup(this.value);
      }
     });
    });
    </script>
    
    <script type="text/javascript">
    	function lookup(inputString) {
    		if(inputString.length == 0) {
    			// Hide the suggestion box.
    			$('#suggestions').hide();
    			
    		} else {
    			$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
    				if(data.length >0) {
    					$('#suggestions').show();
    					$('#autoSuggestionsList').html(data);
    				}
    			});
    		}
    	} // lookup
    	
    	function fill(thisValue) {
    		$('#inputString').val(thisValue);
    		setTimeout("$('#suggestions').hide();", 200);
    		
    	}
    </script>
    </head>
    
    <body>
    
    
    	<div>
    		<form>
    			<div>
    				Type your search:
    				<br />
    				<input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
    			</div>
    			
    			<div class="suggestionsBox" id="suggestions" style="display: none;">
    				<img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
    				<div class="suggestionList" id="autoSuggestionsList">
    					&nbsp;
    				</div>
    			</div>
    		</form>
    	</div>
    
    HTML:
     
    baris22, Feb 2, 2011 IP
  2. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have to use this ajax api from google to get these type of requests to work on my sites

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
    libs/jquery/1.3.0/jquery.min.js"></script>
     
    srisen2, Feb 3, 2011 IP