There are few similar questions in here, but none of them fits me.
I need an effective way to filter options in on select depending on selected value in another select. First select consist of options with simple numeric values 1,2,3... The second one, which should be filtered, consist of options in 'groups'. The values of options are in hundreds i.e. 102, 103, 202, 254...
If the option with value 1 is selected only options with value starting with 1 should be visible in the second select. And this should happen every time user selects one option.
I've tried this piece of code, but it doesn't work.
function filterInstitution(elem){ var currRow = elem.closest("tr") var inType = elem.val(); currRow.find(".CompName option").toggle(false); currRow.find(".CompName option").each(function(){ $("[value^="+ inType + "]", $(this)).toggle(true); }); } Here's the Fiddle. It only contains few options, but in reality, the second select consist of 80+ options.
My idea was to hide all options and show only options starting with selected number from the first select. Where did i go wrong?