Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit: To create a cross-browser solution you really have to move the options around</strong></p> <p>Someone else has already solved the original question so to make this more useful for any future readers, here is a generic version for a select (using data attributes rather than pipe delimited). This jQuery doesn't require an extra hidden select to be created, it will just move the options as hidden siblings of the target select and move them back as required.</p> <p><a href="http://jsfiddle.net/2msfH/" rel="nofollow">http://jsfiddle.net/2msfH/</a></p> <pre><code>&lt;div id="step1"&gt; &lt;input class="radiobutton" data-type="PAT" name="TemplateTypes" type="radio" /&gt;&lt;div&gt;Patient&lt;/div&gt; &lt;input class="radiobutton" data-type="EMPLOYEE" name="TemplateTypes" type="radio" /&gt;&lt;div&gt;Employee&lt;/div&gt; &lt;input class="radiobutton" data-type="MACHINE" name="TemplateTypes" type="radio" /&gt;&lt;div&gt;Machine&lt;/div&gt; &lt;select class="selectLDlist" id="ddlAllTemplates" name="AllTemplates"&gt; &lt;option value="77492" data-type="EMPLOYEE" data-date="08/16/13"&gt;EMPLOYEE&lt;/option&gt; &lt;option value="70470" data-type="PAT" data-date="08/16/13"&gt;Patient&lt;/option&gt; &lt;option value="70472" data-type="PAT" data-date="08/12/13"&gt;Patient&lt;/option&gt; &lt;option value="70472" data-type="EMPLOYEE" data-date="08/13/13"&gt;EMPLOYEE&lt;/option&gt; &lt;option value="70472" data-type="PAT" data-date="8/14/13"&gt;Patient&lt;/option&gt; &lt;option value="70472" data-type="MACHINE" data-date="08/14/13"&gt;MACHINE&lt;/option&gt; &lt;option value="70472" data-type="PAT" data-date="08/14/13"&gt;Patient&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>JQuery:</p> <pre><code>$('.radiobutton').change(function () { var optionsToRemove = $('#ddlAllTemplates option[data-type!=' + $(this).data('type') + ']'); var optionsToBringBack = $('#ddlAllTemplates ~ option[data-type=' + $(this).data('type') + ']'); optionsToRemove.hide().insertAfter('#ddlAllTemplates'); optionsToBringBack.show().appendTo('#ddlAllTemplates'); }); </code></pre> <p><code>$('#ddlAllTemplates ~ option')</code> will bring back all siblings of <code>#ddlAllTemplates</code> that match <code>option</code></p>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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