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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:55:12+00:00 2026-05-27T00:55:12+00:00

I was wondering how to format the source to allow this example : I

  • 0

I was wondering how to format the source to allow this example :

I want to be able to autocomplete the field either by entering the name, or ref, or address which match a single object

So this is mainly a formatting question

id  1 = { name = "test", ref = "1337", address = "123 street" }
    2 = { name = "john", ref = "2", address = "oxford street" }

Here’s what i’ve done so far, but it’s not working. I know that i’m missing something really obvious.

     var autocompleteFields = new Array();

     for (var i in db._data.installations)
     {
         smallArray = [db._data.installations[i].name, db._data.installations[i].reference, db._data.installations[i].address];
         autocompleteFields.push(smallArray);  
     }

      $("#input_search_installation_autocomplete").autocomplete({
            source: autocompleteFields
      });  

}); 

Thanks.

  • 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-05-27T00:55:12+00:00Added an answer on May 27, 2026 at 12:55 am

    Maybe it’s not so trivial solution but it works:

    var data = [
        { id: 1, name: "test", ref: "1337", address: "123 street" },
        { id: 2, name: "john", ref: "2", address: "oxford street" }
    ];
    
    $("#input_search_installation_autocomplete").autocomplete({
            minLength: 1,
            //define callback to format results  
            source: function (req, add) {
                add(getSourceData(req));
            },
    }).data("autocomplete")._renderItem = (function (ul, item) {
    
            if (item == undefined) return;
    
            var label = '<span>' + item.name + " " + item.address + '</span>';
    
            return $("<li></li>").data("item.autocomplete", item).append(label).appendTo(ul);
    });
    
    function getSourceData(req) {
        var source = new Array();
        var query = req.term;
    
        for(var i = 0; i < data.length; i++) {
            var entry = data[i];            
            if (entry.name.indexOf(query) > -1 || entry.ref.indexOf(query) > -1 || entry.address.indexOf(query) > -1) {
                source.push(entry);
            }
        }
        return source;
    }
    

    Code: http://jsfiddle.net/2AUN8/6/

    Hope it helps.

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

Sidebar

Related Questions

This question asking for a phone number format API in Java got me wondering
I was wondering what the best way to format a string would be in
I am wondering how one is supposed to format Objective C code using the
I am wondering if there is a method or format string I'm missing in
I was wondering if InnoDB would be the best way to format the table?
I was wondering if anyone knew of a good way to format files sizes
I'm just wondering what is an ideal output format for the AJAX response? Pure
Hey, I'm just wondering how to convert a numerical date into text format in
Say the source data comes in excel format, below is how I import the
I have XML in the following format: <Products> <Product name=MyProduct1> <Components> <Component name=MyComponent1> <Teams>

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.