473,657 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding the id of a jquery autocomplete input from within the onItemSelect call

15 New Member
i have this,

Expand|Select|Wrap|Line Numbers
  1. $(function() {
  2.        $('#input').autocomplete('test.php', {json: true});
  3.      });
  4.  
that bring back values from the database here is my php section

Expand|Select|Wrap|Line Numbers
  1. $result = mysqli_query($db,$query);
  2.  
  3. while( $row = mysqli_fetch_array($result) )
  4. {    
  5. $aResults[] = array( "id"=>($row['s_id']) ,"value"=>($row['s_last']), "info"=>($row['s_first']) );
  6. }
  7.  
  8. $return = array();
  9.  
  10. foreach ($aResults as $key => $res) {
  11.      $return[] =$res['value'] . ' , ' . $res['info'];
  12.  
  13. }
  14.  
  15.  
  16. echo json_encode($return);
  17.  
  18.  
  19.  
  20.         }
  21.     }
  22. }
  23.  
i would like, when i select a name from the auto suggest to be able to have the id be filled in a input text area...

uncle Google says this, but i am having a hard time implementing it.

Expand|Select|Wrap|Line Numbers
  1. myCallback = function(li, $input) {
  2.     // I need to refer to the appropriate "myXxxInput" here
  3.     alert($input.attr('id'));
  4. }
  5.  
  6. setup = function() {
  7.     setupInput($('#myFirstInput'));
  8.     setupInput($('#mySecondInput'));
  9. }
  10.  
  11. function setupInput($input) {
  12.     $input.autocomplete('blah.php', {onItemSelect: function(li) {
  13.         myCallback(li, $input);} });
  14. }
  15.  
  16.  
Nov 18 '09 #1
0 2301

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2417
by: Kubus | last post by:
Please help, IE 6.0 seems to hava a problem with input form autocomplete dropdown positioning. The dropdown list with last entries which appears normally right below the field but when used within an IFRAME it is offset far down from input field - seems the dropdown is moved down exactly same amount as IFRAME offset from the top of the main document. Simple example: <form method="get"> <input type="text" name="Name" value="">
40
10878
by: Alex | last post by:
Hello, does anybody know how to turn off the autocomplete feature for a certain text field? I am aware of the "autocomplete" attribute, but I have seen other implementions achieving it without any such attribute and am wondering whether there is another way to do it .... like via CSS or a naming convention or .......
15
7226
by: Twan Kennis | last post by:
Hi, I have a DB2 database on the IBM iSeries platform, on which I created several Stored Procedures with the SQLCODE as a return-parameter. These Stored Procedures are called from a Windows application (build in Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access ODBC driver. On the Internet I found a whitepaper "SQL messages and codes" provided by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
0
1284
by: Thorsten Ottosen | last post by:
Hi, I'm using the AutoComplete attribute to control transactions. What happens if I call functions with the AutoComplete attribute from within other functions with the AutoComplete attribute? For example public class Foo
1
3842
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function and send the item number to the xmlHttp and works awesome. Now I need to add an apply button next to it. so they can type in the complete number then hit apply and it does the same function. I cant get it to work with the script I have. The image...
3
3930
by: libsfan01 | last post by:
hi i have a page which contains an visible nav down the left-hand side. when you click a button it needs to appear. i thought it would be cool to use scriptaculous to make it slide down. can anyone give me an example code for this? thanks marc
1
1845
by: c19h28o2 | last post by:
Hi, I'm a little stuck with Ajax (really am not getting it at the moment!) I'm trying to write into a div when something is typed into a box... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>
1
49872
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to get anything to happen. Below is the code. Thanks in advance. jQuery: jQuery(document).ready(function() { jQuery("a").click(function() { jQuery("#dialog").dialog({ modal: true,
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.