I have tried the below to capture the value "1" on checkbox selection and value "0" on unselection of a checkbox. The Problem I am facing is if I select the checkbox, the value "1" is capturing but if I didn't select the checkbox the value="0" is not captured on form data.
JS:
<script>
function setvalue() {
if (document.getElementById('binary').checked = true) {
document.getElementById('binary').value='1';
} else {
document.getElementById('binary').value='0';
}
</script>
HTML:
<input name="Maximize" id="binary" type="checkbox" value=" ">