I have of form which allows for a file uploads, but am trying to have a checkbox which adds/removes a class (disabled)
Heres the HTML
<div class="col-8">
<div class="form-check">
<input class="form-check-input" type="checkbox" onClick="enableUpload()" id="defaultCheck1">
<label class="form-check-label" for="defaultCheck1">
PCR file is compliant
</label>
</div>
</div>
<div class="col-4">
<label class="btn btn-outline-secondary btn-bs-file disabled" id="attach">
<span class="icon-paper-clip"></span>
Attach a PCR file
<input type="file" name="file">
</label>
</div>
the javascript function to be fired when the box is checked
function enableUpload() {
// Get the checkbox
var checkBox = document.getElementById("defaultCheck1");
// Get the output text
var lbl = document.getElementById("attach");
// If the checkbox is checked, display the output text
if (checkBox.checked == true){
lbl.classList.remove('disabled');
} else {
lbl.classList.add('disabled');
}
}