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
satyaprakash palsatyaprakash pal 

select all and deselect all checkbox

1) I have one VF page, I have used <apex:repeat with cehckbox.
ex:

<div class="accordion_head" onclick="javascript: if (isSpinner == 'false'){ isSpinner= 'true'; var child = j$(this).children(0);if (child.attr('class') == 'icon closed'){j$('#dialog-spinner').modal();designCatalog();}}"> Category <span class="icon closed"></span> </div> <div class="accordion_body closed"> <apex:outputPanel id="catPanel" > <apex:repeat value="{!ResultCatalog.categories}" var="category" id="thecategories"> <apex:outputPanel rendered="{!ResultCatalog.categories[category]}"> <label class="label_check c_on " for="{!category}" title="{!category}"> <input id="{!category}" type="checkbox" checked="true" onclick="javascript:doAddLimiter('Job_Category_Description__c','{!category}');" /> {!category} </label> </apex:outputPanel> <apex:outputPanel rendered="{!NOT(ResultCatalog.categories[category])}"> <label class="label_check" for="{!category}" title="{!category}"> <input id="{!category}" type="checkbox" onclick="javascript:doAddLimiter('Job_Category_Description__c','{!category}');" /> {!category} </label> </apex:outputPanel> </apex:repeat> </apex:outputPanel> </div>

2) I want to use a checkbox when i select checkbox all cehckboxes which is comes under <apex:repeat> tag should be get selected.

Please help me, I am new in salesforce technology.
Dushyant SonwarDushyant Sonwar
give checkedone as id which is under apex repeat
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;
            }
        } 
 
satyaprakash palsatyaprakash pal
I created on checkbox <input id="select all" type="checkbox" onclick="checkAll(this)"/>
onclick event i call the above script but it did not work

 
satyaprakash palsatyaprakash pal
have any error in the code ? , please let me know
Dushyant SonwarDushyant Sonwar
Did You Gave Id to those checkbox which is in apex repeat??
satyaprakash palsatyaprakash pal
ID is comming from controller
ex :

<apex:repeat value="{!ResultCatalog.categories}" var="category" id="thecategories"> <apex:outputPanel rendered="{!ResultCatalog.categories[category]}"> <label class="label_check c_on " for="{!category}" title="{!category}"> <input id="{!category}" type="checkbox" checked="true" onclick="javascript:doAddLimiter('Job_Category_Description__c','{!category}');" /> {!category} </label> </apex:outputPanel> <apex:outputPanel rendered="{!NOT(ResultCatalog.categories[category])}"> <label class="label_check" for="{!category}" title="{!category}"> <input id="{!category}" type="checkbox" onclick="javascript:doAddLimiter('Job_Category_Description__c','{!category}');" /> {!category} </label> </apex:outputPanel> </apex:repeat>
 
satyaprakash palsatyaprakash pal

<apex:repeat value="{!ResultCatalog.categories}" var="category" id="thecategories">

 <label class="label_check c_on " for="{!category}" title="{!category}"> <input id="{!category}" type="checkbox" checked="true" onclick="javascript:doAddLimiter('Job_Category_Description__c','{!category}');" /> {!category} </label> 

</apex:repeat>
 
Dushyant SonwarDushyant Sonwar
use this when creating id={!category}-checkedone
satyaprakash palsatyaprakash pal
if i use checkedone then all input will be the same id i.e 'checkedone'
satyaprakash palsatyaprakash pal

<apex:repeat value="{!ResultCatalog.categories}" var="category" id="thecategories">

 <label class="label_check c_on " for="{!category}" title="{!category}"> <input id="checkedone" type="checkbox" checked="true" onclick="javascript:doAddLimiter('Job_Category_Description__c','{!category}');" /> {!category} </label> 

</apex:repeat>
satyaprakash palsatyaprakash pal
Like this ?