JSFiddle - React, Tailwind, and code Playground
by antoinesubit
HTML
<!-- Checkbox who determine if the other checkbox must be disabled -->
<input type="checkbox" id="checkboxDetermine"> Determine checkbox<br/><br/>
<!-- The other checkbox conditionned by the first checkbox -->
<input type="checkbox" id="checkboxConditioned">Conditionned checkbox
JavaScript
// Get your checkbox who determine the condition
var determine = document.getElementById("checkboxDetermine");
// Make a function who disabled or enabled your conditioned checkbox
var disableCheckboxConditioned = function () {
if(determine.checked) {
document.getElementById("checkboxConditioned").disabled = true;
}
else {
document.getElementById("checkboxConditioned").disabled = false;
}
}
// On click active your function
determine.onclick = disableCheckboxConditioned;
disableCheckboxConditioned();