Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery autocomplete function

Posted on 2014-04-11
1
Medium Priority
?
434 Views
Last Modified: 2014-04-11
Hi,
I have the autocomplete function working properly, in that I can send in my terms and return my JSON (to perl).
Here is the JSON I am getting back from my database query via the autocomplete field:
[{"empid":"A9DDDB08-DBF4-4BC0-9F07-E48F08221FBA","value":"David Smith"}]

Here is the jquery/HTML on my page
-----------
$(function() {

$( "#tags" ).autocomplete({
source: "../f/getnames2.pl",
minLength: 2,
dataType: "JSON"
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Name: </label>
<input id="tags" />

Open in new window

------------------


My question is this. How can I get the value of empid from my json to be associated with the value that is returned from auto-complete?
I  need to use the value of empid in another database query so I need to return it when the form is submitted.
I don't really know jquery, I've been trying various things but nothing is working.

Thanks!
Nacht
0
Comment
Question by:nachtmsk
1 Comment
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 2000 total points
ID: 39994975
$( "#tags" ).autocomplete({
  select: function( event, ui ) {
    alert(ui.item.empid);
  }
});

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Six Sigma Control Plans

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question