Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:44:05+00:00 2026-06-10T14:44:05+00:00

I am using the jquery/ajax autocomplete, below is the code snippet of my simple

  • 0

I am using the jquery/ajax autocomplete, below is the code snippet of my simple app:

external .jsp:

    $(function () {
     $("#inputfield").autocomplete({
     source: '/fruitapp/findFruit'
     });
    });

and in my controller:

    def findFruit = {
     def fruitsearch= Fruit.withCriteria {
      ilike 'fruit', params.term + '%'
      }
     render (fruitsearch?.'fruit' as JSON)
    }

As you can see, it will only fill in a single text field which is the “inputfield”. Now, I want that if I select an item from the autocomplete list, it will fill in at least two fields. How would I do it?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:44:07+00:00Added an answer on June 10, 2026 at 2:44 pm

    The autocomplete can get a “select” event. There you can do whatever you want.

    From their documentation

    $( ".selector" ).autocomplete({
       select: function(event, ui) { ... }
    });
    Bind to the select event by type: autocompleteselect.
    $( ".selector" ).bind( "autocompleteselect", function(event, ui) {
      ...
    });
    

    Here is a fiddle I made from their example.
    As you can see, once an autocomplete option is selected, I am updating 2 different divs.

    This is the code responsible for it:

    $( "#tags" ).autocomplete({
                source: availableTags, 
                select:function(e,u){ 
    
    
                    console.log([e,u]);
                    $("#output").text("This is the label:" + u.item.label);
                    $("#more_output").text("this is the value:" + u.item.value);
    
                }
      });
    

    And just to be perfectly clear – “u” can contains anything you want.

    Here I modified the fiddle to contain a single complex JS object. You can access all the fields.

    I added a log print for you to see. Use chrome’s developer tools to see the log print and view objects’ content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Jquery autocomplete ajax function whose source is calculated from code behind.
I am using a JQuery autocomplete AJAX plugin as follows; $(document).ready(function() { $(#myfield).autocomplete({ serviceUrl:'autocomplete.asp?soc='
I'm using django-ajax-selects , which is a freely available django app providing jquery autocomplete
I'm using ajax function to get the data back for my jquery autocomplete but
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
What's benefit using jQuery Autocomplete over Ajax AutoCompleteExtender? Can some one explains the benefits
I'm using jQuery UI, specifically Datepicker and Autocomplete, as follows: <script src=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js></script> <link href=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css
I'm using the jQuery AutoComplete plugin combined with ajax. Do you know how can
I'm using jquery autocomplete <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script> <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js'></script> Everything is working Ok., but now
Using jQuery autocomplete.. Want to replace hello in script below with javascript to identify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.