Hi Guys!

I am creating a jQuery location suggestion tool (i.e. when the user types a location it fetches a list of suggested locations and displays them underneath the input box). You have probably seen something similar on search forms on some websites.

I've written the jQuery which works perfectly well. All I am looking to do now is when the user presses enter it should get the first term returned and select it (i.e. enter it into the input box). So just to clarify:

1. User types a phrase (i.e. Essex)
2. The ajax/jQuery script returns 5 matches for essex (i.e. Brentwood, Essex - Chigwell, Essex etc).
3. The user presses enter and it selects the first match (pre fills the input box with this value).

Any idea how I modify my script to accomodate this?

Here's the script I am using at the moment:
Code JavaScript:
$(document).ready(function() 
{
	$("#location_ajax").keyup(function(event)
	{
		$.get("../ajax/locations.php", { input: $(this).val(), standardajax: '1' },function(data)
		{
			if(data !== "")
			{
				$("#location_results").html(data);
				$("#location_results").show();
			} else
			{
				$("#location_results").hide();
			}
		});
	});
 
	$("#location_ajax_search").keyup(function(event)
	{
		$.get("./ajax/locations.php", { input: $(this).val(), standardajax: '2' },function(data)
		{
			if(data !== "")
			{
				$("#location_results").html(data);
				$("#location_results").show();
			} else
			{
				$("#location_results").hide();
			}
		});
	});
});