Solved

jquery autocomplete function

Posted on 2014-04-11
1
420 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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 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)

912 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

21 Experts available now in Live!

Get 1:1 Help Now