I’m having a trouble with enabling the input fields via a checkbox in the modal dialog. I tried using the code below but it only works with the first data in the modal. When I closed the modal and select the other user, it is not working.
SECOND DATA: As you can see the EDIT button was enabled but the input fields is not.
SCRIPT:
<script>
function enableFields() {
var cb_edit=document.getElementById("cb_edit");
if(cb_edit.checked) {
document.getElementById("user_type").disabled = false;
document.getElementById("stat").disabled = false;
document.getElementById("dept").disabled = false;
document.getElementById("fname").disabled = false;
} else {
document.getElementById("user_type").disabled = true;
document.getElementById("stat").disabled = true;
document.getElementById("dept").disabled = true;
document.getElementById("fname").disabled = true;
}
}
</script>
CHECKBOX BUTTON:
<input class="form-check-input" type="checkbox" id="cb_edit" onclick="enableFields();">
<label class="form-check-label" for="flexSwitchCheckDefault">Edit</label>