Check all checkboxes inside page using JavaScript

InfoPath alternatives for form designing SharePoint
One requirement came recently where we need to check all the checkboxes inside the page. So here we will discuss how we can check or uncheck all the checkboxes using javascript.
You may also like:
Check all Checkboxes:
<input type=’button’ id=’1234′ value=’Check All’ onclick=”checkAllItems();”/>
<script language=”javascript” type=”text/javascript”>
function checkAllItems() {
var tags = document.getElementsByTagName(“input”);
for (var i =0; i < tags.length; i++){
if (tags[i].type == ‘checkbox’)
tags[i].checked = true;
}
}
</script>
UnCheck All Checkboxes:
<input type=’button’ id=’4321′ value=’Check All’ onclick=”uncheckAllItems();”/>
<script language=”javascript” type=”text/javascript”>
function uncheckAllItems() {
var tags = document.getElementsByTagName(“input”);
for (var i =0; i < tags.length; i++){
if (tags[i].type == ‘checkbox’)
tags[i].checked = false;
}
}
</script>
Hope this will work.

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply