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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:23:46+00:00 2026-06-04T21:23:46+00:00

Is there a way to tell jQuery UI Autocomplete which JSON array indexes to

  • 0

Is there a way to tell jQuery UI Autocomplete which JSON array indexes to use as the ‘label’ and ‘value’ when those aren’t the index names used in the JSON array?

The aray containing my lookup values looks like this (as logged by Firebug):

[ Object { id="12", name="Don Davis" }, Object { id="17", name="Stan Smith" } ]

I want to use ‘id’ as the ‘label’ and ‘name’ as the ‘value’ but can’t figure out how to tell the config object.

My array is contained in a local variable — there’s no Ajax call being made.

This response to another question solves the problem by creating a hidden form input, but it seems likely that there’s a cleaner way of handling 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-04T21:23:47+00:00Added an answer on June 4, 2026 at 9:23 pm

    From reading the Jquery UI docs you can try something like this:

    <script>
        $(function() {
    var projects = [ { id: "12",value: "Don Davis" }, { id: "17", value:"Stan Smith" } ]
    
        $( "#project" ).autocomplete({
            minLength: 0,
            source: projects,
            focus: function( event, ui ) {
                $( "#project" ).val( ui.item.value);
                return false;
            },
            select: function( event, ui ) {
                $( "#project" ).val( ui.item.value);
                $( "#project-id" ).val( ui.item.id);
    
                return false;
            },
            search: function(event, ui) { console.log(event); console.log(ui) }
        })
        .data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.value+"</a>" )
                .appendTo( ul );
        };
    });​
        </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given two jquery objects, Is there some way I tell which one is further
Is there a way to tell ReSharper to use the String and Int64 type
Is there a way to tell (on UNIXes) which of a process's memory pages
Is there a way to tell jQuery that you want what ever comes after
Is there any way to tell jQuery to do something only once? E.g. right
If there a way to tell if the jQuery Mobile select menu is open?
I'm trying to use the jQuery autocomplete plugin. I have an array of IDs
Is there a way to tell maven to continue the build although a dependency
Is there a way to tell Tomcat 7 the path to the JVM that
Is there a way to tell debugging tools (firebug and the likes) never to

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.