Adding condition to jQuery Form Checkbox

Adding condition to jQuery Form Checkbox

I have a jQuery form consisting of checkboxes where the boxes can have values,

Name [X] or [Y] or [Z]

Class [1] or [2] or [3]

The main script goes like this,

<script>
$(document).ready(function(){
      function displayVals() {
var NameValue = $("#Name").val();
var ClassValue = $("#Class").val();
                  
                  var AllValue = "?q=Name_s%3A" +  NameValue + "|Class_s:" + ClassValue;

                  var finderValue= "[A website Address]"+AllValue; 

                  $("#DetailFinderForm").attr("action", finderValue);
}
$("select").change(displayVals);

                displayVals();

});
</script>

It is all working fine but I would like to apply a condition where in, if we select a certain value in Name Checkbox, only few values are displayed in Class Checkbox.

Example:If I select X - Display only 1 & 2,
              If I select Y - Display only 2 & 3 
              if I select Z - Display 1, 2 & 3.

Can some one please help me how to go about it?

Thank you.