Jump to content
funbinod

keyboard select on autosuggest using jquery

Recommended Posts

i'm trying to learn jquery. while learning i'm trying autosuggest and i tried this

<script type="text/javascript">	function lookup(inputString) {		if(inputString.length == 0) {			// Hide the suggestion box.			$('#suggestions').hide();		} else {			$.post("item.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>

it is working properly... but i wish the suggestion could be selected using up and down arrows on keyboard. can anyone suggest how can i do that?

Share this post


Link to post
Share on other sites

You'll need to add a keydown or keypress handler to the page which would check if the list is open, which item has focus, and move the focus.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...