function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mansimansi 

'Select all' check box functionality- javascript

NareshKrishnaNareshKrishna

Hi Mansi,

 

Use sample below, it will help you to resolve the issue:

 

Javascript:

---------------

function checkAll(cb) 

var inputElem = document.getElementsByTagName("input"); 
for(var i=0; i<inputElem.length; i++) 

if(inputElem[i].id.indexOf("checkedone")!=-1) 
inputElem[i].checked = cb.checked; 

}

 

apex page:

---------------

<apex:dataTable value="{!usersInfo}" var="user" >
<apex:column >
<apex:facet name="header"> 
<apex:inputCheckbox > 
<apex:actionSupport event="onclick" onsubmit="checkAll(this)" />
</apex:inputCheckbox> 
</apex:facet> 
<apex:inputCheckbox  id="checkedone"/>
</apex:column> 
<apex:column headerValue="UserName" >
<apex:outputText value="{!user.userName}"></apex:outputText> 
</apex:column>
</apex:dataTable>

 

Thanks.