top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get CheckBox status whether it is checked or not?

+7 votes
369 views
How to get CheckBox status whether it is checked or not?
posted Feb 10, 2014 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

you can use something like document.getElementById("variable").checked to see if a checkbox is checked or not -

See the following sample code -

<html>
    <head>
        <script language="javascript" type="text/javascript">
            function exefunction(){
                var lfckv = document.getElementById("lifecheck").checked;
                alert(lfckv);
            }
        </script>
    </head>
    <body>
        <label><input id="lifecheck" type="checkbox" >Lives</label>
        <button onclick="exefunction()">Check value</button>
    </body>
</html>
answer Feb 11, 2014 by Jai Prakash
...