Add “selected” class to custom taxonomy dropdown search

$seach_values can be changed whenever the site redirect, be sure that $search_values still keeps the input values from your search form.

To be sure I suggest use GET or POST to pass the values from form. So, your comparing statement should be

$_GET['grades'] == $term->slug

Here I suppose your search form use method="GET"