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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:55:25+00:00 2026-06-10T09:55:25+00:00

I am using autocomplete where each variable being searched has 3 attributes (label, id,

  • 0

I am using autocomplete where each variable being searched has 3 attributes (label, id, value). I want the value of a users selection to be passed to one of four hidden fields based on the id of that selection.

js file

var destinations= [
        {value: "25",label: "USA",id: "1"},
        {value: "26",label: "Midwest",id: "2"},
        {value: "27",label: "Colorado",id: "3"},
        {value: "28",label: "Denver",id: "4"}
        ];

$(document).ready(function() {
    $( "#destinations" ).autocomplete({
        minLength: 1,
        source: destinations,

        select: function( event, ui ) {
            $('#destinations').val( ui.item.label );
            $('#destinationid').val(ui.item.id);
            $('#destinationtype').val(ui.item.value);
            if ($("#destinationid").val() == 1){
            $("#results1").text($('#type1').val());
        }
        if ($("#destinationid").val() == 2){
            $("#results2").text($('#type2').val());
        }
        if ($("#destinationid").val() == 3){
            $("#results3").text($('#type3').val());
        }
        if ($("#destinationid").val() == 4){
            $("#results4").text($('#type4').val());
        }
    },

        focus: function( event, ui ) {
            $("#destinations").val( ui.item.label );
            return false;
        }
    });

});

In my html, I have the following: (i don’t have them hidden for testing purposes.)

<input id="destinations" /> 
<input type="hidden" input id="type1" /> 
<input type="hidden" input id="type2" />
<input type="hidden" input id="type3" />
<input type="hidden" input id="type4" /> 

The autoselect is pulling the labels fine, but when i select one, it changes the selection to its value rather than keeping the label. It is also not putting the value in the corresponding text box and just leaving the value in the first text box.

Any suggestions would be appreciated.

  • 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-10T09:55:26+00:00Added an answer on June 10, 2026 at 9:55 am

    I was able to figure it out thanks to Jason pointing me in the right direction. Its not perfect yet, but its doing what I want. http://jsfiddle.net/pkracer/RADGs/

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

Sidebar

Related Questions

I want to make autocomplete work on each textboxes using with an attribute kolonadi
I am using autocomplete feature in jquery to show the users list intellisense. for
Using the Pluralsight demos found in asp.net I created autocomplete textbox. I want to
I'm using two jquery ui widgets, autocomplete and tabs. They each have their own
Im using jQuery UI autocomplete. When i use a local variable as source it
What I want to do is have categorised results using autocomplete through jQueryUI's function.
I have implemented an autocomplete using jquery-ui. I want to limit the number of
would love your thoughts on this one. I am using jQuery autocomplete in a
i have an input using the jquery autocomplete plugin. with this i want to
I am using jQuery.autocomplete(1.02) on my search box and I want exact string and

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.