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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:05:29+00:00 2026-06-11T12:05:29+00:00

have 5 Select controls on a page, each with the same option values and

  • 0

have 5 Select controls on a page, each with the same option values and when I select one value in first dropdown, I shouldn’t be allowed to select the same value again in the others. I tried something like below.

$("#div").find(".selectClass").live("change", function (e) {
    var selectedValue = $(this).val();
    var controlId = $(this).attr("id");
    var isPropertyAlreadySelected = false;

    $("#div").find(".selectClass").each(function () {
        var currentSelect = $(this);
        if (controlId != currentSelect.attr("id") && currentSelect.val() == selectedValue) {
            isPropertyAlreadySelected = true;
        }
    });

    e.preventDefault();
    return false;
});

EDIT: Removed check on the flag “isPropertyAlreadySelected”; but still I’m able to select other dropdown values.

Even if I do a “return false” or “e.preventDefault()”, the value is still getting selected in the other dropdowns. Please point me in the right direction. 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-06-11T12:05:31+00:00Added an answer on June 11, 2026 at 12:05 pm

    The problem you are running in is, that the value of the select has already changed when your change event fires.

    You need to have a list of the currently selected values and reset the changed option here:

    if (isPropertyAlreadySelected) {
        // Reset here
    }
    

    Just fill an array with the values that are selected at page load and update this array every time an option gets selected.

    I have just tested with the mousedown event. This one fires before the option realy got selected. Try here: http://jsfiddle.net/g3rsF/1/

    This will not solve for all cases, as the user can select by keypress also.

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

Sidebar

Related Questions

i have select <select id=parentId name=parentId><option value=1>ФАСАДНАЯ ШТУКАТУРКА&lt;BR /&gt;&lt;B&gt;&amp;#0171;STUC-O-FLEX&amp;#0187;&lt;/B&gt;</option> <option value=2>ФОНТАНЫ И САДОВАЯ МЕБЕЛЬ&lt;BR
I have a web page with several HTML Select controls that all allow multiple
I have two tabs in my home page and each tab has one jquery
I have select values as follows: <select id=SelectBox multiple=multiple> <% foreach (var item in
I have a page with a ScriptManager, a generic HTML drop-down list ( <select>
I have an ASP.NET page that's going to use Html controls to render a
I have a FormView bound to a SqlDataSource on my page. One of the
So I have a loop going that pulls posts onto the page. Each post
I have a value stored in Google App Engine datastore, selected from a dropdown
i have an xhtml page with menu and tab controls(with datatable) of primefaces. the

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.