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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:23:16+00:00 2026-05-26T15:23:16+00:00

Currently, I have two drop down lists that are populated with users’ first and

  • 0

Currently, I have two drop down lists that are populated with users’ first and last names. When a user is selected from the first drop down list, the name is unavailable in the second drop down list.

I would like to add a third drop down list that makes the values selected in the first and second lists unavailable. How may I modify my current code to support this feature?

The current code may be found here: http://jsfiddle.net/NfTNA/

    function removeOptions(selectA,selectB,selectC) {
    var firstValue = $(selectA).children(":selected").attr("value");
    var secondValue = $(selectB).children(":selected").attr("value");
    var thirdValue = $(selectC).children(":selected").attr("value");
    // get the other element from the hidden select to put back
    var prior = $("#hiddenContainer").children("[value!="+secondValue+"]").data("prior");
    if (prior != undefined) {
        $("#hiddenContainer").children("[value!=" + secondValue + "]").insertAfter($(selectB).children("[value=" + prior.prior + "]"));
    }
    if (firstValue != 0) {
        // add the prior id data to the element before removing it
        var priorValue = $(selectB).children("[value="+firstValue+"]").prev().attr("value");
        $(selectB).children("[value="+firstValue+"]").data("prior",{prior:priorValue});

        // move the selected element of selectA in selectB to hidden select 
        $(selectB).children("[value="+firstValue+"]").appendTo("#hiddenContainer");
    }
    // reselect the option in the secondary select
    $(selectB).val(secondValue);

}

Thanks in advance.

  • 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-26T15:23:17+00:00Added an answer on May 26, 2026 at 3:23 pm

    To do this with jQuery (see http://jsfiddle.net/NfTNA/38/)

    Example markup

    <label for="reviewer">Select 1<sup>st</sup> Reviewer:</label>
    <br />
    <select name="optionsA" id="optionsA">
        <option value="">&ndash; select &ndash;</option>
        <option value="jsmith">Smith, John (jsmith)</option>
        <option value="bwright">Wright, Bob (bwright)</option>
    </select>
    <br />
    <label for="reviewer">Select 2<sup>nd</sup> Reviewer:</label>
    <br/>
    <select name="optionsB" id="optionsB">
        <option value="">&ndash; select &ndash;</option>
        <option value="jsmith">Smith, John (jsmith)</option>
        <option value="bwright">Wright, Bob (bwright)</option>
    </select>
    <br />
    <label for="reviewer">Select 3<sup>rd</sup> Reviewer:</label>
    <br/>
    <select name="optionsC" id="optionsC">
        <option value="">&ndash; select &ndash;</option>
        <option value="jsmith">Smith, John (jsmith)</option>
        <option value="bwright">Wright, Bob (bwright)</option>
    </select>
    

    jQuery

    var firstSelected = null;
    var secondSelected = null;
    
    //initally order select lists (this is a bit of cheat, to help later on
    
    $('#optionsA').change(function() {
        //remove the currently selected option from 2nd/3rd drop down
        var selectedValue = $('#optionsA option:selected')
        if (selectedValue.val() != "") {
            $('#optionsB option[value="' + selectedValue.val() + '"]').remove();
            $('#optionsC option[value="' + selectedValue.val() + '"]').remove();
        }
        else {
            selectedValue = null;
        }
    
        //add previous item back in to 2nd/3rd drop down
        if (firstSelected != null) {
            $('#optionsB').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text())); 
            $('#optionsC').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text())); 
        }
    
        //save the currently selected value
        firstSelected = selectedValue;
    });
    
    $('#optionsB').change(function() {
        //remove the currently selected option from 1st/3rd drop down
        var selectedValue = $('#optionsB option:selected')
        if (selectedValue.val() != "") {
            $('#optionsA option[value="' + selectedValue.val() + '"]').remove();
            $('#optionsC option[value="' + selectedValue.val() + '"]').remove();
        }
        else {
            selectedValue = null;
        }
    
        //add previous item back in to 1st/3rd drop down
        if (secondSelected != null) {
            $('#optionsA').append($('<option>', { value : secondSelected.val() }).text(secondSelected.text())); 
            $('#optionsC').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text())); 
        }
    
        //save the currently selected value
        secondSelected = selectedValue;
    });
    

    This is based on the following:

    • select an option from select list 1, removes option from select lists 2 and 3

    • select an option from select list 2, removes option from select lists 1 and 3

    • previously selected options are added back into lists

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

Sidebar

Related Questions

I am trying to write an MVC webpage that has two drop down lists.
I (currently) have two forms, one that needs to call the other. In other
All, I currently have two projects that are under SourceSafe that I am unable
Currently I have two pages: The first page contains an input form, and the
I currently have an asp.net website hosted on two web servers that sit behind
I have a drop down list and some styles applied to it from two
I have an internal application that I needs to have a drop down list
I have 3 drop down (combo boxes) or select lists on a page. It
I have a drop down list with two values (for now..) with other elements
I have two drop down. SelCurrentManuf and selCurrentModel. I want the option in selCurrentModel

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.