Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-15-2011, 08:42 PM   PM User | #1
rajsid
New to the CF scene

 
Join Date: Apr 2011
Location: San Francisco
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
rajsid is an unknown quantity at this point
New guy with a question about the jQuery Autocomplete feature

I am using this on a website that I am building.
http://jqueryui.com/demos/autocomplete/default.html

If I type in "Co" in the field in the URL above, it shows a few suggestions, but I want to take the user to a URL or another HTML page when they click on one of the suggestions.

How do you link the values to another page?

Thanks
Raj
rajsid is offline   Reply With Quote
Old 04-16-2011, 08:55 AM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
If you're just holding the possible lookups locally, as opposed to a database, then something like:

Code:
$(function() {
var webSites = [{value:"Google",url:"http://www.google.com"},{value:"Coding Forums",url:"http://codingforums.com"}];
 
//autocomplete
$("#lookup").autocomplete({
    source: webSites,//look up the variable already created
    minLength: 2,//search after two characters,
    select: function(event,ui){
		window.location.href =  ui.item.url;//on select, navigate to the url selected
		}
    });
	
});
ought to do the job. UI Autocomplete shows the field 'value' in the dropdown, here we're also retrieving a field 'url', which we then use to load a new page on select.

If you're holding the data in a database then it's pretty much the same principle, but obviously you'd need to connect to and retrieve from the database.
SB65 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:43 AM.


Advertisement
Log in to turn off these ads.