Hi there
Im a relative newbie and am trying to have a searchbar that users can complete, with the text entry being from a pre-defined list. The hope is that a new page will open with the link that relates to the search bar entry.
Im using an Autocomplete code but cant work out how to get the link part to work. See below code
[CODE]<html>
<head>
<script src=”jquery-latest.js”></script>
<link rel=”stylesheet” href=”http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css” type=”text/css” />
<link rel=”stylesheet” href=”http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css” type=”text/css” />
<script type=”text/javascript” src=”http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js”></script>
<script type=”text/javascript” src=”http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js”></script>
<script type=”text/javascript” src=”http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js”></script>
<script>
$(document).ready(function(){
var data = “092 610 343 505 Utilities”.split(” “);
$(“#example”).autocomplete(data);
});
var data = [ {text:’Link A’, url:’/page2′}, {text:’Link B’, url: ‘/page2’} ];
$(“…”).autocomplete(data, {
formatItem: function(item) {
return item.text;
}
}).result(function(event, item) {
location.href = item.url;
});
</script>
</head>
<body>
Number: <input id=”example” /><p></p>
</body>
</html>
Can someone help me complete this code? For example, how can I change the code so that a text entry of “092” opens “www.google.com” when I hit enter after text entry?
Your help with this is greatly appreciated
Glen