Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery to go to an optgroup label
    primarykey
    data
    text
    <p>I have a dropdown setup for searching. The idea is you click one option, Then the OPTGROUP appears. What I'd like to do is once the label is selected it jumps to that section of the OPTGROUP.</p> <p>I have written some jQuery so far. See this <a href="http://jsfiddle.net/aNhzY/" rel="nofollow">jsFiddle</a> - So once you select a main category. I would like the optgroup to go to its paired label. How can I achieve this?</p> <p><strong>HTML</strong></p> <pre><code>&lt;select id="category" name="category"&gt; &lt;option selected="selected" value="0"&gt;Choose a category...&lt;/option&gt; ... &lt;option value="4"&gt;Photography&lt;/option&gt; &lt;/select&gt; &lt;select multiple="multiple" id="subcategory" name="category_ids[]"&gt; &lt;optgroup label="Art Styles"&gt; &lt;option value="5"&gt;Abstract&lt;/option&gt; ... &lt;option value="18"&gt;Graphics&lt;/option&gt; &lt;/optgroup&gt; &lt;optgroup label="Art Subjects"&gt; &lt;option value="19"&gt;Animals&lt;/option&gt; ... &lt;option value="45"&gt;Dreams &amp;amp; Nighmares&lt;/option&gt; &lt;/optgroup&gt; &lt;optgroup label="Media"&gt; &lt;option value="46"&gt;Water Colour&lt;/option&gt; ... &lt;option value="56"&gt;Mixed Media&lt;/option&gt; &lt;/optgroup&gt; &lt;optgroup label="Photography"&gt; &lt;option value="57"&gt;Color Photography&lt;/option&gt; ... &lt;option value="64"&gt;Celebrity Photography&lt;/option&gt; &lt;/optgroup&gt; </code></pre> <p> Portrait Landscape Square </p> <p><strong>JavaScript</strong></p> <pre><code>// Search Options Dropdown // Hide Subcategory Dropdown $('#subcategory').css('display', 'none'); // Hide Orientation Dropdown $('#orientation').css('display','none'); $('#category').change(function() { $('#subcategory').css('display', 'block'); $('#orientation').css('display', 'block'); var CatValue = $("#category").val(); if (CatValue == '1') { } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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