Auto Select checkbox Script

 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 -->


  • Release Date - 20-08-2009
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy the javascript code into <head> tag of your page.
  • Call the function chksel() which will act as a keystroke for selecting all other checkboxes.
  •   For eg,<input type=checkbox onclick="chksel()">Check all</input>
  • Use this auto select checkboxes script anywhere in your web page, where you need to check / uncheck all items.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question