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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:19:10+00:00 2026-06-14T13:19:10+00:00

I have 4 select inputs with the same options. and I am trying to

  • 0

I have 4 select inputs with the same options. and I am trying to disable any option that has been selected from one of these selects.

<select name="homeTeams[]" onchange="check()">
    <option value="1">Team1</option>
    <option value="2">Team2</option>
    <option value="3">Team3</option>
    <option value="4">Team4</option>
</select>

<select name="homeTeams[]" onchange="check()">
    <option value="1">Team1</option>
    <option value="2">Team2</option>
    <option value="3">Team3</option>
    <option value="4">Team4</option>
</select>


<select name="awayTeams[]" onchange="check()">
    <option value="1">Team1</option>
    <option value="2">Team2</option>
    <option value="3">Team3</option>
    <option value="4">Team4</option>
</select>

<select name="awayTeams[]" onchange="check()">
    <option value="1">Team1</option>
    <option value="2">Team2</option>
    <option value="3">Team3</option>
    <option value="4">Team4</option>
</select>

I am trying to disable the option that has been selected from one of these selectors. I am using jQuery to do it, but I can’t get the value based on the sender.

Ex: if the user has chosen Team1 from Select 1 the jQuery code will disable the option Team1 from Select2 and Select3 and Select4.

  function check()
  {
      var a = $('select option:selected').val();
      alert(a);
  }

it gives me the value of the first select.

any Ideas ?

  • 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-14T13:19:11+00:00Added an answer on June 14, 2026 at 1:19 pm

    Here’s my solution – note the ‘0’ value for “- select -” which allows any value to be deselected:

    $('select').on('change', function() {
        var vals = {};
        $('select').each(function(i, el) {
            vals[el.value] = 1;
        });
        delete vals[0];
    
        $('option').prop('disabled', function() {
            return this.value in vals && this.value !== this.parentElement.value;
        });
    });​
    

    demo at http://jsfiddle.net/alnitak/Qq33g/

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

Sidebar

Related Questions

I have a table where one column is selects. The same options but selected
I have this code to hide selected options: function connect() { $(.selectbox option).show(); $(.selectbox).each(function(i)
I have a bunch on elements with the same name that i am trying
I'm trying to create a function where a user should select an option from
I have two select controls that I want to populate with the exact same
I have a set of select inputs representing a users birthday: birthyear, birthmonth and
I have this select input in my form that I want to access via
i have one form which have some input box and some select box. i
I am trying to learn rails from zero programming experience and have an app
I have a select field that is dynamically populated with an ajax call that

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.