Filter DDL based on selection of other DDL : <p>If I have a dropdownlist that looks like this:</p>

<pre><code>&lt;select class="form-control" id="FirstDDL" name="FirstDDL"&gt;
    &lt;option value="1"&gt;Option1&lt;/option&gt;
    &lt;option value="2"&gt;Option2&lt;/option&gt;
    &lt;option value="3"&gt;Option3&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>And another dropdownlist that looks like this:</p>

<pre><code>&lt;select class="form-control" id="SecondDDL" name="SecondDDL"&gt;
    &lt;option value=""&gt;Select Option&lt;/option&gt;
    &lt;optgroup label="Option1"&gt;
        &lt;option value="12"&gt;SubOption1Value1&lt;/option&gt;
        &lt;option value="13"&gt;SubOption1Value2&lt;/option&gt;
        &lt;option value="14"&gt;SubOption1Value3&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;optgroup label="Option2"&gt;
        &lt;option value="49"&gt;SubOption2Value1&lt;/option&gt;
        &lt;option value="50"&gt;SubOption2Value2&lt;/option&gt;
        &lt;option value="51"&gt;SubOption2Value3&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;optgroup label="Option3"&gt;
        &lt;option value="33"&gt;SubOption3Value1&lt;/option&gt;
        &lt;option value="34"&gt;SubOption3Value2&lt;/option&gt;
        &lt;option value="35"&gt;SubOption3Value3&lt;/option&gt;
    &lt;/optgroup&gt;
&lt;/select&gt;
</code></pre>

<p>Now, based on the selection of the first dropdownlist, I want the second dropdownlist to be filtered.</p>

<p>So if I select <code>Option1</code> in the first dropdownlist.. then the second dropdownlist should show only the options under <code>&lt;optgroup label="Option1"&gt;</code></p>

<p>I have this so far:</p>

<pre><code>$(document).ready(function () {

    $("#FirstDDL").change(function () {
        var selectedOption = $("option:selected", this);
        var selectedText = selectedOption.val();

        switch (selectedText) {
            case 1:
                // here is where I need to set the values of the second dropdownlist
        }

    });
});
</code></pre>

<p>Any help is appreciated.</p>
