I need to hardcode those of the values of the checkboxes which are enabled/disabled, depending on the selected option value. I was trying to do something like this:
$("#Units").on("change", function () {
if ($(this).val() !== "Finance") {
$(".dissable").val("3").prop("disabled", true);
$(".dissable").val("4").prop("disabled", true);
} else {
$(".dissable").val("3").prop("disabled", false);
$(".dissable").val("4").prop("disabled", false);
}
}).trigger('change');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<select id="Units">
<option value="Marketing" > Marketing </option>
<option value="Finance" > Finance </option>
<option value="Operations" > Operations </option>
</select>
<input type="checkbox" class="dissable" onclick="check();" value="1"> chbx1
<input type="checkbox" class="dissable" onclick="check();" value="2"> chbx2
<input type="checkbox" class="dissable" onclick="check();" value="3"> chbx3
<input type="checkbox" class="dissable" onclick="check();" value="4"> chbx4
But no desired effect, which is supposed to be like this:
- When I choose an option other then "Finance", checkbox no. 3 and 4 are disabled.
- For "Finance", all checkboxes are enabled.
I need to do this based on the checkbox values, not only class.