html file:
<html>
<body>
<label>
<input type="checkbox" name="postcheckbox" />
demo checkbox
</label>
</body>
</html>
I want to get the value of changed state of checkbox in my controller.
html file:
<html>
<body>
<label>
<input type="checkbox" name="postcheckbox" />
demo checkbox
</label>
</body>
</html>
I want to get the value of changed state of checkbox in my controller.
By using Js
var checkbox = document.querySelector("input[name=postcheckbox]");
checkbox.addEventListener('change', function() {
if (this.checked) {
console.log("Checkbox is checked..");
//pass to model
} else {
console.log("Checkbox is not checked..");
//pass to model
}
});