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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:36:35+00:00 2026-05-21T03:36:35+00:00

I have 3 selects with a couple of options. When an option is changed

  • 0

I have 3 selects with a couple of options. When an option is changed I want to check all of the other selects, whether they are also selected or not (selected=”selected”). All of the selects are in the same form.

So far I have the following javascript to do that

$("#form").change(function(event){  
 $(this).find("select").each(function(){
    alert( $(this+"option:selected").length );
 });
});

Basically following this approach: Check if option is selected with jQuery, if not select a default

The alert doenst seem to give me 1 or 0 based on the individual $(this) select element, but strangely counts up to 2 (alerts 3 times 2 after the last select is selected. After the first select it alerts 3 times 0, after the second 3 times 1, and 3 times 2 on the last). I want it to alert for example 0 0 0, then 1 0 0 then 1 0 1 and finally 1 1 1.

Any idea how this comes and how to accomplish the wanted? thx.

  • 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-21T03:36:36+00:00Added an answer on May 21, 2026 at 3:36 am

    Your inner selector is incorrect. It should be:

    $(this).find("option:selected").length
    

    You can’t prepend a dom element to a selector (since they are not strings). You’ll end up with a selector that looks something like “Object objectoption:selected” since it will implicitly call the .toString() method as it is being used with the dual purpose + operator.

    jQuery selectors need to be well-formed CSS3 selectors.

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

Sidebar

Related Questions

I have a checkoxlist with a couple of items and an all option. The
I have a select element with a couple of dates but I also want
I have a select statement and in a couple of the fields, I want
All, I have multiple selects on my page all with the same class. The
I want a field to become required only when a specific option is selected
I have a couple of .properties files I want Eclipse to pick up. According
I have a select widget with a couple of AJAX enhancements. <select id=authors> <option
I have a couple select elements: <select name=empID onchange='setSupervisor(this);'> <option value=111 sid=222>Eric Employee</option> ...
I'd like to have a simple select input box with a couple options for
I have a drop-down where users can select a couple of options. Can I

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.