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

  • Home
  • SEARCH
  • 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 6855501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:45:59+00:00 2026-05-27T01:45:59+00:00

Please go through the below fiddle. I am trying to get the ids of

  • 0

Please go through the below fiddle. I am trying to get the ids of the selected products in the fcbkcomplete box and show it as comma separated values in the textbox with id="interest". I wrote a function to achieve that but it didn’t work. The function adds the id of the first value and not taking the ids of the other values which are added in the multiple selection box.

http://jsfiddle.net/balac/xDtrZ/1/

I have added json.txt. it contains datas like this

[{"key":"2", "value":"Canon Powershot "},{"key":"3", "value":"Fastrack Bag"},{"key":"4", "value":"Iphone 4 "},{"key":"5", "value":"Levis Jeans"},{"key":"7", "value":"Indig"},{"key":"8", "value":"Dashing Cars"},{"key":"9", "value":"dsdas"},{"key":"10", "value":"fsfs"}]

In the above json value key is the id which I want to display in the textbox as comma separated values. value is the value which will be coming in the dropdown for selection.

while selecting the values in the drop down i want the corresponding key to get added in the textbox as comma separated values.

The problem is that only the key of the first selected item is getting added in the textbox, no matter.

Hope am specific and said all in detail. if anyone want any clarification please ask me i will explain more.

  • 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-27T01:46:00+00:00Added an answer on May 27, 2026 at 1:46 am

    I think I found a simpler solution for you. Keep in mind, due to the problems I mentioned in my comments I had to drastically simplify your fcbkcomplete code to get it working..

    $(document).ready(function() {
        $("#select3").fcbkcomplete({
            addontab: true,
            maxitems: 10,
            input_min_size: 0,
            height: 10,
            select_all_text: "select",
            onselect: clicker
        });
    });
    
    var clicker = function() {
        var selected = new Array();
    
        $('option', this).each(function() {
            selected.push($(this).val());
        });
    
        $('#interest').val(selected.join(', '));
    };
    

    See it in action here.

    Note: I had to manually add <option>'s to the select list to get fcbkcomplete to actually work right. But nevertheless, my logic should work for you regardless.

    Also, fcbkcomplete apparently dynamically changes the <option>'s id to something like opt_vaQDzJU37ArScs818rc8HUwz9gm1wypP so I had to use the value instead. There are workarounds for that if you’re dead set on using the id instead of the value.

    To illustrate my point, modify the loop through each option like this:

    $('option', this).each(function() {
        for (var i = 0; i < this.attributes.length; i++) {
            var pair = this.attributes[i].name + ': '
                + this.attributes[i].value;
            alert(pair);
        }
        selected.push($(this).val());
    });
    

    You will see how the attributes end up after fcbkcomplete runs.

    Final Edit

    After setting it up on localhost and using a JSON txt file, I was able to finally replicate the problem you were having. The thing is, the behavior totally changes when you use JSON instead of hard-coding the <option>s. Here is your working solution:

    $(document).ready(function() {
        var clicker = function(e) {
            var selected = new Array();
    
            // using "this" here was out of context, use #select3
            $('option', $('#select3')).each(function() {
                selected.push(this.value);
            });
    
            $('#interest').val(selected.join(', '));
        };
    
        $("#select3").fcbkcomplete({
            json_url: "parseJSON.txt",
            addontab: true,
            maxitems: 10,
            input_min_size: 0,
            height: 10,
            select_all_text: "select",
            onselect: clicker
        }); 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please go through the code below. String[] Info contains 2 values like this: shiftDirection
Please look through code below: // A.class File file = new File(blah.txt); FileWriter fileWriter
I need a function that will go through below values and print out the
Please go through the python code snippet below import subprocess child = subprocess.Popen(python ./myprog.py
Please go through the simple scenario below, I couldn't find a better way to
In my application I'm able to get all MMS through code below, but I
I am trying to make an AJAX Request through JQuery The below is my
I am trying to insert values into Oracle 10g database using the code below
Please have a look on code written below. I am trying to have a
Can someone please point out whats going wrong here: The code below loops through

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.