Reputation: 21
<input id="idCheckbox" name="check" type="checkbox" value="AllValue" style="width: auto; height: auto; font-weight: bolder;" data-bind="checked: idCheckbox" />
Always getting the same value (AllValue) if the checkbox is unchecked also.
var AllPoliciesChk = document.getElementById("idCheckbox").value;
Upvotes: 1
Views: 351
Reputation: 366
try it, its working fine for me. I have used jquery here is the working example in jsfiddle https://jsfiddle.net/26Ltymkx/
jquery code
var AllPoliciesChk = document.getElementById("idCheckbox").value;
$(document).on('click', '#idCheckbox', function(){
if ($('#idCheckbox').is(":checked")) {
//...your code
}
}
})
Upvotes: 2