I am trying to change the value of a checkbox input based on whether the checkbox input is checked or not checked. Here is what I have:
HTML:
<input type="checkbox" id="chkPrint" name="Print" value="false" onclick="myFunction()">
JavaScript:
function myFunction() {
var chkPrint = document.getElementById("chkPrint");
if (chkPrint.checked == true) {
chkPrint.value = "true";
}
}
function yourFunction() {
if (document.getElementById("chkPrint").checked == false) {
document.getElementById("chkPrint").value = "false";
}
}
yourFunction()
When I look at my HTML in the Chrome DevTools, I see my value change to true. However, if I were to uncheck it, then the value would remain true.