I have a toggle on button in my Application.
If the button ist toggled on, I want that the value is set to 1, and if not the value should be null. (0=deactivated, 1=activated)
Thats my current javascript code:
var checkbox = document.querySelector("input[name=checkbox]");
checkbox.addEventListener( 'change', function() {
if(this.checked) {
document.getElementById("activate").value = '1';
} else {
document.getElementById("deactivate").value = '0';
}
});
And thats my toggle button:
<div class="toggle">
<label>
<input id="CheckAcitavtion" name="checkbox" type="checkbox">
<span class="slider"></span>
</label>
</div>
But at the moment when I toggle the button the following error shows up:
Uncaught TypeError: Cannot set property 'value' of null at HTMLInputElement.