How to find checkbox is checked in JavaScript

{0 Comments}

To find if checkbox is checked or not then you can use checked term with checkbox id can be use to get Boolean value the “true”,”false”. In following code sample there is a variable which get the Boolean value according the status of checkbox. So you can use following code sample to check if checkbox is checked or not. 

 HTML |  copy code |? 
01
<head>
02
        <title>Get status of checkbox</title>
03
        <script type="text/javascript">
04
        function exefunction(){var boolvalue = document.getElementById("mycheckbox").checked;
05
           alert(boolvalue);}
06
        </script>
07
    </head>
08
    <body>
09
        <form id="form1">
10
        <div>
11
                <label>
12
                    <input id="mycheckbox" type="checkbox">TRY THIS
13
                </label>
14
            <button onclick="exefunction()">Get boolean value</button>
15
        </div>
16
        </form>
17
    </body>

Leave a Comment

Your email address will not be published.