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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:28:05+00:00 2026-05-28T20:28:05+00:00

I have 2 drop-down menus. User selects something from the first one, then the

  • 0

I have 2 drop-down menus. User selects something from the first one, then the options that are displayed within the second are filtered based on the first selection.

My strategy is to .hide() all of the options in the second drop-down if they are not relevant.

The function I wrote properly identifies which items in the second drop-down list should be hidden and adds the style=”display:none” attribute to those options.

The problem is that the second drop-down list appears to have nothing in it after you select something from the first.

Here is all the JS. The HTML should be able to be inferred fairly easily. The items in the second drop-down list have been tagged with a class name that matches an option from the first option list.

$(document).ready(function () {
    $('.part-type').change(function () {
        $(this).show();
        var part_type = "."+$(".part-type option:selected").text().toLowerCase();
        $('.part').children().filter(":not("+part_type+")").hide();
    })
});

Thanks to all my friends on SO.

Link to my work in action on JsFiddle –> http://jsfiddle.net/hwD8K/

  • 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-28T20:28:06+00:00Added an answer on May 28, 2026 at 8:28 pm

    Unfortunately, you can’t use CSS to affect the display of options in a select.

    Your best bet is probably to store the values in a data field on the select, and then filter that data field on every change and re-set the contents of the select every time.

    Or, instead of show() and hide() you could probably detach the undesired options from the DOM and reattach them later.

    For more thoughts on this, see this question:

    How can I hide select options with JavaScript? (Cross browser)

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

Sidebar

Related Questions

I want to have a drop down menu where a user can select from
I have a select drop-down that selects a theme for the current page the
I have two drop down menus, one of which I am trying to replace
So, I have an animated drop down menu that slides down when your mouse
I have a drop down menu that looks like this: It works fine, but
I have result that I want to display as a drop down menu. The
within a form I have a section that allows the user to build out
I have two Drop Down Lists, the second ones are based off which one
I have a form where a user selects a file, and then should be
I have two drop down menus on my website. Technologies used are Javascipt ,

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.