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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:09:39+00:00 2026-05-17T18:09:39+00:00

I need to create an interface that upon selection of a parent multi select,

  • 0

I need to create an interface that upon selection of a parent multi select, it updates a child multi select of options. It is intended that the parent multi select can have none, one or many options selected and the child element displays a union of items that both parents have (or falls back to all items).

Take for example:

  • When parent 1 is selected, all status items for parent 1 should be allowed to be selected
  • When parent 1 and parent 2 are selected all status items that are allowed within both parent 1 and 2 should be allowed to be selected in the child element

After searching around here and doing a lot of googling I think I have got close, but this solution unfortunately does not fully satisfy the second requirement.

I may be approaching this totally the wrong way, so I’m open to suggestions.

The JS:

$(document).ready(function(){

var allOptions = $('#children option').clone();

function children_update() {
    $('#parents > option:selected').each(function() { 
        $('#children').html(allOptions.filter('.option-' + parseInt($(this).val())));    
    });
    if(!$('#parents > option:selected').length) { $('#children').html(allOptions); }
}

children_update();

$('#parents').change(function() { children_update(); });
});

The HTML

    Parents<br />
<select multiple name="parents[]" id="parents">
<option value="1">parent 1</option>
<option value="2">parent 2</option>
<option value="3">parent 3</option>
</select>

<br />
Children<br />
<select multiple name="children[]" id="children">
<option value="1" class="option-1">child 1 (1)</option>
<option value="2" class="option-1 option-2">child 2 (1,2)</option>
<option value="3" class="option-1 option-2 option-3">child 3 (1,2,3)</option>
<option value="4" class="option-1 option-2">child 4 (1,2)</option>
<option value="5" class="option-2">child 5 (2)</option>
<option value="6" class="option-3">child 6 (3)</option>
</select>

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-17T18:09:40+00:00Added an answer on May 17, 2026 at 6:09 pm

    How about changing the children_update function to this…

    function children_update() {
        $("#children option").attr('disabled','true');   //start off with all disabled
        $('#parents > option:selected').each(function() {
            var num = $(this).val();
            $("#children .option-"+num).attr('disabled','false');
        });
        if(!$('#parents > option:selected').length){           //if no parents selected
            $("#children option").attr('disabled','false');    //enable all options
        }
    }
    

    If I understand the problem correctly, that should work. However, if you’re doing a more strict combinatorial thing (like only showing child options that match the exact combination of parent options), then please feel free to correct me on this.

    EDIT:

    Okay, here’s a new solution:

    function children_update() {
        $("#children option").attr('disabled','true');   //start off with all disabled
        var selectors = getSelectors();
        $("#children option"+selectors).attr('disabled','false');
    }
    
    function getSelectors(){
        var parents = $("#parents").val();
        var selectors = "";
        if (parents){
            $.each(parents, function(index, val){
                selectors = selectors + ".option-" + val;
            });
        }
        return selectors;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build a user interface to edit and create xml documents that
If I have an interface with a few methods. Sometimes I need to create
I need to create an application that should have several themes. It means that
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a backup of a SQL Server 2005 Database that's only
I need to create a button that has the same style as ButtonSpec with
I have a data access API that say looks something like: public interface IDataAccess
I need to create a historical timeline starting from 1600's to the present day.
I need to create a linked server to a DB2 database on a mainframe.
I need to create an ASP page (classic, not ASP.NET) which runs remote shell

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.