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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:03:47+00:00 2026-05-25T06:03:47+00:00

I am attempting to show drop down options in a second selection drop down

  • 0

I am attempting to show drop down options in a second selection drop down menu based off the selection made on the first drop down menu. In this example, the first drop down menu has 3 selections each with their own unique class. The second dropdown menu has several drop down options with class values that match the class values from the first drop down. By default, the 2nd drop down options are hidden until the user chooses a drop down option from the first selection. My goal is that once the user makes there selection from the first drop down option, to then add a class of “display_block” to the options in the 2nd drop down menu that have the same class value made from the selection in the first drop down box.

Here is the HTML:

<label class="label_bra_band_size">
<span class="store_level_3_brasize">Band Size</span></label>
<select id="product_band_size" name="band_size">
<option value="">Select Band Size</option>
<option value="32" class="a293">32</option>
<option value="34" class="a310">34</option>
<option value="36" class="a323">36</option>
</select>

<label class="label_cup_size">
<span class="store_level_3_brasize">Cup Size</span></label>
<select id="product_cup_size" name="cup_size">
<option value="">Select Cup Size</option>
<option value="A" class="a293" style="display:none;">A</option>
<option value="B" class="a293" style="display:none;">B</option>
<option value="C" class="a293" style="display:none;">C</option>
<option value="D" class="a310" style="display:none;">D</option>
<option value="E" class="a310" style="display:none;">E</option>
<option value="F" class="a310" style="display:none;">F</option>
<option value="G" class="a323" style="display:none;">G</option>
<option value="H" class="a323" style="display:none;">H</option>
<option value="I" class="a323" style="display:none;">I</option>
</select>

Here is the jQuery below. Here’s my logic in the jQuery: when someone makes a selection from the first option, we store the selection class in a variable (ProductBandSize). Then in the 2nd part we compare the options in the 2nd drop down against the variable value. If the 2nd dropdown option has the same class as the variable, add a class of “display_block”. Unfortunately all the options in the 2nd drop down class are getting the class value of “display_block”.

<script type="text/javascript">
$(function(){
  $("#product_band_size").change(function(){
    //When the user changes the Band size, get the Cup Size and assign it to a variable
    var ProductBandSize = $("#product_band_size option:selected").attr("class");
    //Compare the Product Cup Size options against the variable "ProductBandSize"
    if ($("#product_cup_size option").hasClass(ProductBandSize)) {
        //If the product cup size option has the same class value as the first option selected add class display_block to it.
        $("#product_cup_size option").addClass("display_block");
    }
  });
});
</script>
  • 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-25T06:03:48+00:00Added an answer on May 25, 2026 at 6:03 am

    You should use filter to find the matching option which has that class and then add the class. hasClass will only say true/false if the class is present or not. Try this

    $("#product_band_size").change(function(){
        //When the user changes the Band size, get the Cup Size and assign it to a variable
        var ProductBandSize = $("#product_band_size option:selected").attr("class");
        //Compare the Product Cup Size options against the variable "ProductBandSize"
    
        $("#product_cup_size option").filter("."+ProductBandSize).addClass("display_block");
    
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to show a div tag based on the root url of my
I am attempting to show data in rows of three like this (notice the
I am attempting to get a sample jqgrid example to show up on my
This is my first blackberry app and I am attempting to make a simple
EDIT I made a screen shot to show better what I'm attempting to do,
I am attempting to get my app to open a settings menu screen and
I'm attempting to use the Super Inplace Controls plugin, which has an in_place_select method.
I am attempting to show both a ListView and ListBox on a Windows Form
I am attempting to show a specific form using a treeview control, the nodes

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.