jQuery: how to choose options in another selection based off a class in the first selection
<p>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.</p>

<p>Here is the HTML:</p>

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

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

<p>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".</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(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");
    }
  });
});
&lt;/script&gt;
</code></pre>
