I am trying to create a button that when clicked replaces the value in the field true false. If we click the first time the field becomes true, if the second time the field becomes false. But I still can't get the results. The field only changes true.
Checkbox: <input type="checkbox" id="myCheck">
<button onclick="check()">Check Checkbox</button>
<script>
function check() {
var value = document.getElementById("myCheck");
if (value = "false") {
document.getElementById("myCheck").checked = true;
} else {
document.getElementById("myCheck").checked = false;
}
}
</script>