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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:28:32+00:00 2026-06-09T12:28:32+00:00

I will have 3 <select multiple=multiple> and I would like to fill them using

  • 0

I will have 3 <select multiple="multiple"> and I would like to fill them using a JSON array.

{
"folders": [
    {
        "name": "folderName1",
        "files": [
            {
                "name": "filesName1",
                "item": [
                    {
                        "name": "itemName1"
                    }
                ]
            }
        ]
    },
    {
        "name": "folderName2",
        "files": [
            {
                "name": "fileName2",
                "item": [
                    {
                        "name": "itemName2"
                    }
                ]
            }
        ]
    }
]
}

And I would like to fill the 1st select using the ALL folder – names.

And then filter the content of the other selects using the selected value in the first select box. For example when I select foldername1 in the first select I would like to show only option fileName1 in the second select and itemName1 in the third select;

Is it possible to achieve that using jQuery?

Until now I have the following: http://jsfiddle.net/dvMv9/26/

  • 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-09T12:28:33+00:00Added an answer on June 9, 2026 at 12:28 pm

    Here is working code, and a link on fiddle.

    http://jsfiddle.net/yPDGA/

    <select multiple="multiple" id="sel_1"></select>
    <select multiple="multiple" id="sel_2"></select>
    <select multiple="multiple" id="sel_3"></select>
    
    $(document).ready(function(){
        var my_json = {
        "folders": [
            {
                "name": "folderName1",
                "files": [
                    {
                        "name": "filesName1",
                        "item": [
                            {
                                "name": "itemName1"
                            }
                        ]
                    }
                ]
            },
            {
                "name": "folderName2",
                "files": [
                    {
                        "name": "fileName2",
                        "item": [
                            {
                                "name": "itemName2"
                            }
                        ]
                    }
                ]
            }
        ]
        };
    
        var i, html = "";
        for (i = 0; i < my_json.folders.length; i += 1) {
            html += '<option value="' + my_json.folders[i].name + '">' + my_json.folders[i].name + '</option>';
        }
        $("#sel_1").html(html);
    
        $("#sel_1").change(function () {
            var html = "", i, j;
            for (i = 0; i < my_json.folders.length; i += 1) {
                if (my_json.folders[i].name === $(this).attr("value")) {
                    for (j = 0; j < my_json.folders[i].files.length; j += 1) {
                        html += '<option value="' + my_json.folders[i].files[j].name + '">' + my_json.folders[i].files[j].name + '</option>';
                    }
                    $("#sel_2").html(html);
                    $("#sel_3").html('');
                    return;
                }
            }
    
        });
    
        $("#sel_2").change(function () {
            var html = "", i, j, k, sel_1_value = $("#sel_1").attr("value");
            for (i = 0; i < my_json.folders.length; i += 1) {
                if (my_json.folders[i].name === sel_1_value) {
                    for (j = 0; j < my_json.folders[i].files.length; j += 1) {
                        if (my_json.folders[i].files[j].name === $(this).attr("value")) {
                            for (k = 0; k < my_json.folders[i].files[j].item.length; k += 1) {
                                html += '<option value="' + my_json.folders[i].files[j].item[k].name + '">' + my_json.folders[i].files[j].item[k].name + '</option>';
                            }
                        }
                    }
                    $("#sel_3").html(html);
                    return;
                }
            }
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of countries that I will be using in a select
I currently have a select-case that will read a name field from a recordset,
I have two queries. The first will return multiple rows: SELECT parent_entry_id,child_entry_id FROM exp_playa_relationships
I have a select 'All' checkbox that I would like to be bound to
I will explain my problem. I have a select with multiple options, and one
I have a wx.ListBox that I would like the user to select from as
I have a jqGrid with which users will select records. A large number of
I have a few SQL (Select/Update/Insert) syntax that I will run inside PL/SQL one
I have to create a field where I will be able to select between
I have a project where the requirements is that a end user will select

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.