Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Also changed your HTML a bit. Streamlined. <a href="http://jsfiddle.net/mwk97/" rel="nofollow">http://jsfiddle.net/mwk97/</a></p> <h2>jQuery</h2> <pre><code>$('document').ready(function() { var currentList; $('select[name="topselect"]').on('change', function () { $('select:not("[name=topselect]")').hide(); currentList = this.value; $('select[name="select'+currentList+'"]').show(); }); $('.subselect').on('change', function() { $('.subsub').hide(); var nameSelector = '[name="sub' + currentList + 'select' + this.value + '"]'; $('select'+nameSelector).show(); }); }); </code></pre> <h2>HTML</h2> <pre><code>&lt;select name="topselect"&gt; &lt;option&gt;Select Something&lt;/option&gt; &lt;option value="1"&gt;Selecting this displays select1&lt;/option&gt; &lt;option value="2"&gt;Selecting this displays select2&lt;/option&gt; &lt;/select&gt; &lt;select name="select1" class="subselect"&gt; &lt;option&gt;Select Something&lt;/option&gt; &lt;option value="1"&gt;This displays sub1select1&lt;/option&gt; &lt;option value="2"&gt;this displays sub1select2&lt;/option&gt; &lt;/select&gt; &lt;select name="sub1select1" class="subsub"&gt; &lt;option&gt;La Dee Da 11&lt;/option&gt; &lt;option&gt;La Dee Da 11&lt;/option&gt; &lt;/select&gt; &lt;select name="sub1select2" class="subsub"&gt; &lt;option&gt;La Dee Da 12&lt;/option&gt; &lt;option&gt;La Dee Da 12&lt;/option&gt; &lt;/select&gt; &lt;select name="select2" class="subselect"&gt; &lt;option&gt;Select Something&lt;/option&gt; &lt;option value="1"&gt;This displays sub2select1&lt;/option&gt; &lt;option value="2"&gt;this displays sub2select2&lt;/option&gt; &lt;/select&gt; &lt;select name="sub2select1" class="subsub"&gt; &lt;option&gt;La Dee Da 21&lt;/option&gt; &lt;option&gt;La Dee Da 21&lt;/option&gt; &lt;/select&gt; &lt;select name="sub2select2" class="subsub"&gt; &lt;option&gt;La Dee Da 22&lt;/option&gt; &lt;option&gt;La Dee Da 22&lt;/option&gt; &lt;/select&gt; </code></pre> <p>And of course just a little...</p> <h2>CSS</h2> <pre><code>.subselect { display: none; } .subsub { display: none; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload