This Javascript is used to check/uncheck all items by a single click. Auto select or unselect all the items by simply clicking on check all / uncheck all Checkboxes. This script can be used for mutiple checkbox selections.
Features
This is a free javascript to auto select all checkboxes.
Click on check all checkbox to make multiple selection.
Click on uncheck all checkbox to deselect multiple selection.
Saves time as check/uncheck is performed by single selection.
Preview
Auto select checkboxes :
Item1
Item2
Item3
Item4
Check all
Uncheck all
Downloads
Javascript
<!--Script by hscripts.com--> <!-- more scripts @ https://www.hscripts.com --> <script type="text/javascript"> function chksel() { var tab = document.getElementById("div1") var chk = tab.getElementsByTagName("input"); var num = chk.length; var x= document.getElementById("unchkbox"); x.checked = false; for (var i = 0; i < num; i++) { status = chk[i].getAttribute("type"); if ( status == "checkbox") { chk[i].checked = true; } } } function unchk() { var tab = document.getElementById("div1") var chk = tab.getElementsByTagName("input"); var num = chk.length; for (var i = 0; i < num; i++) { status = chk[i].getAttribute("type"); if ( status == "checkbox") { chk[i].checked = false; } } } </script> <!-- Script By hscripts.com -- >
HTML Code
<!-- Script by hscripts.com --> <div id="div1"> <input type=checkbox>Item 1 <input type=checkbox>Item 2 <input type=checkbox>Item 3 <input type=checkbox>Item 4 <input type=checkbox onclick="chksel()">Check all </div> <div id="div2"> <input type=checkbox onclick="unchk()" id='unchkbox'>Uncheck all </div> <!-- Script by hscripts.com -->