The options in my "States" drop-down menu are all being hidden
I'm trying to filter based on the value of the Country drop-down which is selected.
$('#Content_C003_Country').change(function() { const filter = $(this).val(); //console.log(filter); $("#Content_C003_State option").each(function() { ($("option[value^='" + filter + "']") != -1) ? $(this).hide(): $(this).show(); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <select id="Content_C003_Country" class="searchFieldDrop"> <option value="36">Canada</option> <option value="222">United States</option> </select> <select id="Content_C003_State" class="searchFieldDrop"> <option value="36-AB">Alberta</option> <option value="36-BC">British Columbia</option> <option value="36-MB">Manitoba</option> <option value="222-AZ">Arizona</option> <option value="222-AR">Arkansas</option> <option value="222-CA">California</option> </select>
( $("option[value^='" + filter + "']") != -1 )You'll probably want to compare the value with.val()