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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:24:32+00:00 2026-05-15T17:24:32+00:00

I set up my jQuery like so . It successfully lets me pick an

  • 0

I set up my jQuery like so.

It successfully lets me pick an option only once throughout the 3 dropdowns.

However, if I remove a dropdown (use the convenient button), an option is forever disabled (greyed out).

You’ll see what I mean. First, ensure that it works and you can not select the same option more than once.

Now, remove and notice that one has been disabled, and it can never be selected again.

I don’t know why it is forever greying out my option? It seems to keep picking it up when making the selectedIndexes array.

Does anyone know how to get around this problem?

  • 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-15T17:24:33+00:00Added an answer on May 15, 2026 at 5:24 pm

    I made some changes to your code, you can see them here. It also did not work for my in the beginning, but now it works, I think, as expected. If you have questions, just comment 🙂


    Here we go:

    Redeclare the $selects array once you remove an element. The reference to the element is still in the array, so when you later compute the selected indexes, it will still be there!

    select.next('button').click(function(event) {
            event.preventDefault();
    
            select.remove();
           $(this).remove();
           $selects = $('select');  // <-- redeclare selects here, one is gone!
    });
    

    In the select click handler, use nth-child instead of eq. The former one will select all options that are the ith child of their parents. Whereas eq will only select the ith element from the set of matched elements (i.e. it will only return one element). Note that the index of nth-child is one-based.

    // Remove them from this dropdown
    $.each(selectedIndexes, function(i, index) {
    
      // use n-th child here to get the child of each select.
      // eq only selects the element from the matched set
      $thisSelect.find('option:nth-child('+(index+1)+')').attr("disabled","disabled");
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to set for(AssociatedControlID) attribute using jQuery? I am trying something like
I am using the jQuery datepicker( http://keith-wood.name/datepick.html ) and I would like to set
So, I want to use jquery to set the text of a button, depending
i would like to use jquery ui selectmenu from felixnagel. it works but i
When I need to disable/re-enable validator I usually use jQuery code like so: ValidatorEnable($('[id*=DueDateRequiredValidator]')[0],
I would like to use jQuery to refresh a partial on a page, but
How can I set jQuery's ajax tab's url dynamically in runtime? Doing like this:
I am trying to set up library like jQuery simply for learning purposes. I
I need to set up jquery to cycle through tables, making sure it shows/hides
I have included Zend_Form_Element_Hash into a form multiplecheckbox form. I have jQuery set to

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.