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 8267761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:38:57+00:00 2026-06-08T05:38:57+00:00

I have a jquery autocomplete widget that is displaying items with custom data. They

  • 0

I have a jquery autocomplete widget that is displaying items with custom data.

They all have a value, and description.
Currently the value is inserted into the textbox when an item is clicked and the value of an item is what is searched

What I’d like to do is have the filter use both the value and the description when filtering items to display, but keep only the value being inserted.

How can I achieve this?

  • 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-08T05:38:58+00:00Added an answer on June 8, 2026 at 5:38 am

    If you give the autocompleter an array of objects with value and label (rather than description) properties, it will do the filtering for you, but only on the label (not the value).

    If you specify a function for the source option, you’re expected to do the filtering yourself. You receive a request argument (an object with a term property) and a response argument (a function to call back with the results). You then return relevant results yourself, using any kind of search you like (e.g., you can search both value and description in your code).

    E.g., loosely:

    $("some selector").autocomplete({
        // ...other options...
        source: function(request, response) {
            var matches = [];
            /* ...search for matches in your data using `request.term`,
               add them to `matches`...
            */
            response(matches);
        }
    });
    

    The array you return can be just strings, or it can be objects with value and label properties. The label will be shown, the value will be used when selected.

    So for example, here’s one using a (short) list of airports, where when you type it checks both the value (the airport code) and the description (the airport name): Live copy | source

    jQuery(function($) {
      var data = [
        {value: "ORD", description: "Chicago O'Hare"},
        {value: "LHR", description: "London Heathrow"},
        {value: "SFO", description: "San Francisco International"}
      ];
    
      $("#theInput").autocomplete({
        source: function(request, response) {
          var capterm = request.term.toUpperCase();
          var matches = $.map(data, function(entry) {
            if (entry.value.toUpperCase().indexOf(capterm) !== -1 ||
                entry.description.toUpperCase().indexOf(capterm) !== -1) {
              return {
                value: entry.value,
                label: entry.value + " - " + entry.description
              };
            }
          });
          response(matches);
        }
      });
    });
    

    So typing “or” or “chic” will show you “ORD – Chicago O’Hare”, and selecting it will put “ORD” in the field. Typing “san” or “sfo” will show you “SFO – San Francisco International” and selecting it will put “SFO” in the field.

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

Sidebar

Related Questions

I have an autocomplete widget that displays text w/ images. Currently my results look
Mornin' all, I have troubles to play with jQuery UI autocomplete widget events. I
I have a Jquery UI autocomplete code that grabs data from an ajax request,
I have a jQuery autocomplete input box for time. It lists all available times
I have implemented the jquery ui autocomplete as in the example: autocomplete with custom
I've recently added the JQuery autocomplete plug in and have a textbox that autocompletes
I'm using JQuery UI's autocomplete widget and would like to have access to the
I'm using Joomla 1.5. I have created a custom component that pulls data out
I have a jQuery autocomplete entry that I want to make look more like
I am trying to get the jQuery autocomplete widget to get the data from

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.