Note that there are some explanatory texts on larger screens.

plurals
  1. POfiltering only previously unselected <select> options qith JQuery
    primarykey
    data
    text
    <p>Previously I asked how to do this and was directed to this:</p> <pre><code>&lt;script&gt; jQuery.fn.filterByText = function(textbox) { return this.each(function() { var select = this; var options = []; $(select).find('option').each(function() { options.push({value: $(this).val(), text: $(this).text()}); }); $(select).data('options', options); $(textbox).bind('change keyup', function() { var options = $(select).empty().scrollTop(0).data('options'); var search = $.trim($(this).val()); var regex = new RegExp(search,"gi"); $.each(options, function(i) { var option = options[i]; if(option.text.match(regex) !== null) { $(select).append( $('&lt;option&gt;').text(option.text).val(option.value) ); } }); }); }); }; &lt;/script&gt; </code></pre> <p>(<a href="http://www.lessanvaezi.com/filter-select-list-options/" rel="nofollow">http://www.lessanvaezi.com/filter-select-list-options/</a>)</p> <p>When I use this filter on the select box it filters both the unselected AND the selected. I'd like it to ONLY filter the unselected because if a user wants to ammend the selections and filters again, the previously selected items go away - unless they meet the filter criteria.</p> <p>I'm not that good at JavaScript or JQuery and can't understand how I might tell the above script to ignore options that are ":selected" but filter all else.</p> <p>Here's a jfiddle if it helps: <a href="http://jsfiddle.net/UmKXy/" rel="nofollow">http://jsfiddle.net/UmKXy/</a> I'd like option one and two to remain selected and in the list when user begins to type.</p> <p>Thanks for help!</p>
    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.
    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