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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:03:49+00:00 2026-05-28T04:03:49+00:00

I have a set of drop down lists (8 in all). All drop downs

  • 0

I have a set of drop down lists (8 in all). All drop downs have the same set of drop down options available to them. However the business requirement is to make sure that the user cannot select the same option more than once.

Looking at the problem, at first it appears simple but it’s rapidly becoming lots of code. However it seems like a relatively common problem. Does anyone know of a solution, have any tips on how to do this without writing reams of Javascript. Some sort of reusable jquery plugin might be handy for this too. Does one exist?

One issue is that when a select item is chosen, it then becomes unavailable to the other select lists. The item is removed from the other select drop downs. When it becomes available again (a drop down changes) it needs to be inserted at the correct point in the list (the drop down options have an order). This is the bit where my solution has started to get quite complex.

  • 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-28T04:03:50+00:00Added an answer on May 28, 2026 at 4:03 am

    Personally, the way I’d implement it is to have a “master” drop down containing all possible options, simply for the purpose of caching. These options are then replicated in each of the “slave” drop downs. Whenever any slave drop down is changed, they’re all re-populated again to ensure that no two drop downs can share the same selected value.

    For the purpose of demonstration, I’ve only worked with 3 drop down lists in the code below, but it should scale up pretty easily. Just add mode drop downs and make sure they contain the attribute class="slave".

    Also, if you want any of the options to be immune from being removed, so that it’s possible to exist in all of your slave drop downs (such as the default option in the code below), just add the attribute class="immune" to the option tag in the master drop down.

    <script type="text/javascript">
    
        // document - on load
        $(document).ready(function() {
    
            // initially populate all the drop downs
            PopulateAllDropDowns();
    
            // populate all drop downs on each subsequent change
            $('select.slave').change(function(){
                PopulateAllDropDowns();
            });
    
        });
    
        function PopulateAllDropDowns()
        {
            // populate all the slave drop downs
            $('select.slave').each(function(index){
                PopulateDropDown($(this).attr('id'));
            });
        }
    
        function PopulateDropDown(id)
        {
            // preserve the selected value
            var selectedValue = $('#'+id).val();
    
            // clear current contents
            $('#'+id).html('');
    
            // attempt to add each option from the master drop down
            $('select#ddlTemplate').children('option').each(function(index){
    
                // scope-safe var
                var masterOptionValue = $(this).val();              
    
                // check if option is in use in another slave drop down, unless it's immune
                var optionInUse = false;
                if (!$(this).hasClass("immune"))
                {
                    $('select.slave option:selected').each(function(index){
                        if (masterOptionValue == $(this).val() )
                            optionInUse = true;
                    });
                }               
    
                // if it's not in use, add it to this slave drop down
                if (!optionInUse)
                {
                    // create new option
                    var newOption = $('<option></option>').val($(this).val()).html($(this).text());
    
                    // ensure selected value is preserved, if applicable
                    if (selectedValue == $(this).val())
                        newOption.attr('selected', 'selected')
    
                    // add the option                   
                    $('#'+id).append(newOption);
                }
    
            });
        }       
    </script>
    

     

    <form>
    
        <!-- master drop down -->
        <select id="ddlTemplate" class="master" style="display:none">
            <option value="" class="immune">Select ...</option>
            <option value="a">Option A</option>
            <option value="b">Option B</option>
            <option value="c">Option C</option>
            <option value="d">Option D</option>
            <option value="e">Option E</option>
        </select>
    
        <!-- slave drop downs -->
        <select id="ddlOne" class="slave"></select>
        <select id="ddlTwo" class="slave"></select>
        <select id="ddlThree" class="slave"></select>
    
    </form>
    

    Hope that helps.

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

Sidebar

Related Questions

I have a C#.Net MVC3 web app. I am using Drop Down lists all
I have a set of drop down controls on a view that are linked
i have 2 drop downs in my UI,selecting one would give another set of
Say that I have a web user control that has several drop down lists
I have a drop down list whose4 datasoruce is already set, I need to
I have an iframe which contains a few select drop-down lists for data entry.
I have a bunch of drop down lists in my view, such as this
I have a page that has two drop down lists on it and a
EDIT: The drop down menus have the following listed in them: Typing Course Daily
I have a method that finds all the controls, iterates through them, determines if

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.