How to : Select or Unselect all checkboxes using javascript
Introduction
There are cases where we want to select all the checkboxes or unselect all the checkboxes, but their count are so many that we get irritated. Our users of the website or the system might feel the same thing. So whats the best solution : A checkbox which says select all and unselect all the options.
Description
Below code is a combination of Javascript and HTML, which represents a mechanism to select all the checkboxes and unselect all the checkboxes.
Benefits
1) A single checkbox to select all the checkboxes
2) A single checkbox to deselect all the checkboxes
3) There can be any number of check boxes, there is no restriction on the number of check boxes.
Code
<script type="text/javascript">
var checked=false;
var frmname='';
function checkedAll(frmname)
{
var valus= document.getElementById(frmname);
if (checked==false)
{
checked=true;
}
else
{
checked = false;
}
for (var i =0; i < valus.elements.length; i++)
{
valus.elements[i].checked=checked;
}
}
</script>
<form id ="cbexample">
<input type="checkbox" name="chk1">Apple
<input type="checkbox" name="chk2">Banana
<input type='checkbox' name='checkall' onclick='checkedAll("cbexample");'>Select All
</form>












[...] the rest here: How to : Select or Unselect all checkboxes using javascript | My … Related Posts:php checkboxes How to get the value php checkboxes with submit?I want to write a PHP [...]
[...] here to see the original: How to : Select or Unselect all checkboxes using javascript | My … Share and [...]
[...] the original: How to : Select or Unselect all checkboxes using javascript | My … Related Posts:HTML Checkboxes, Radio Buttons and Select Form Fields HTMLBlog: Kate Moss Dresses » [...]
[...] This post was mentioned on Twitter by Abhishek Sanghvi, Abhishek Sanghvi, Abhishek Sanghvi, Abhishek Sanghvi, Abhishek Sanghvi and others. Abhishek Sanghvi said: How to : Select or Unselect all checkboxes using javascript http://bit.ly/daaq9q [...]
thanks
very nice yr script language
very nice yr script language……………
Thanks for the great tip…javascript and php work well together…I appreciate it
Thank you, very nice and simple script. It works like magic. Greetings from HUNGARY