Solved

jquery autocomplete function

Posted on 2014-04-11
1
417 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 500 total points
ID: 39994975
$( "#tags" ).autocomplete({
  select: function( event, ui ) {
    alert(ui.item.empid);
  }
});

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now