G.vigneshwari
G.vigneshwari

Reputation: 21

Always getting the same value if the checkbox is unchecked also

  1. Input checkbox will be like this
    <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

Answers (1)

khan Farman
khan Farman

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

Related Questions