select all checkbox JavaScript
select all checkbox javascript |
HI guys in this script we are going tom learn how to select and unselect all checkbox using JavaScript.
Just use the below codes to implement how to select and deselect all checkbox using JavaScript.
index.html
<html> <head> <script> function check() { var check=document.getElementsByTagName('input'); for(var i=0;i<check.length;i++) { if(check[i].type=='checkbox') { check[i].checked=true; } } } function uncheck() { var uncheck=document.getElementsByTagName('input'); for(var i=0;i<uncheck.length;i++) { if(uncheck[i].type=='checkbox') { uncheck[i].checked=false; } } } </script> <style> #content { text-align:center; margin:0 auto; padding:0px; width:500px; } input[type="button"] { background:none; border:1px solid green; width:100px; cursor:pointer; height:50px; border-radius:5px; margin:10px; font-weight:bold; } input[type="checkbox"] { width:20px; height:20px; } td{ font-weight:bold; } </style> </head> <body> <div id="content"> <input type="button" value="Select All" onclick="check();"> <input type="button" value="Remove All" onclick="uncheck();"> <table align='center' cellspacing='10'> <tr> <td><input type="checkbox"></td> <td>CodeNair</td> </tr> <tr> <td><input type="checkbox"></td> <td>Web Development</td> </tr> <tr> <td><input type="checkbox"></td> <td>PHP MySQL</td> </tr> <tr> <td><input type="checkbox"></td> <td>AJAX</td> </tr> </table> </div> </body> </html>
That's it Friends how to select and unselect all checkbox using JavaScript.
stay with us for more codes ..Thank you...
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.