Link to home
Start Free TrialLog in
Avatar of CPL593H
CPL593HFlag for Belgium

asked on

Load a page according to jQuery's autocomplete plugin

This should be trivial.

See the snippet below, using jQuery's autocomplete plugin (http://docs.jquery.com/Plugins/Autocomplete). It gives me two input boxes, one in which I can search users by their last name, the other by their username. I type a few letters, get a few suggestions, press enter and the last name or username appears. Up to that part, the documentation was good enough.

Then the documentation begins to go in all directions and seems to forget to explain the obvious: once I've found the person, I probably want to see his profile page after selecting him/her. Since I've loaded PHP arrays, it's really just opening the profile page for user number X.

So my question is simple: suppose that I autocomplete to Jack Smith, and want to see his profile page by clicking the enter key, (i.e., opening, say, user_profiles.php?user_id=332), what do I have to add to the snippet?
<script type="text/javascript" src="jquery/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="jquery/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="jquery/jquery.autocomplete.pack.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
	$("#last_names").autocomplete("get_last_names_array.php");
});
$(document).ready(function() {
	$("#usernames").autocomplete("get_usernames_array.php");
});
//-->
</script>
<p>Find by last name: <input type="text" id="last_names" /></p>
<p>Find by username: <input type="text" id="usernames" /></p>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ali_pakkan
ali_pakkan
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial