Simple script to select all checkboxes generated by tag <apex:selectCheckboxes>.

VF Page:

<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-2.1.4.js')}"  />
    <script>
        $j = jQuery.noConflict();

        $j(document).ready(function() {
            selectAll_Click();
        });

        function selectAll_Click(){
            $j("input[name='selectAll']").on("click", selectAllBoxes);
        }

        function selectAllBoxes(){
            if ($j("input[name='selectAll']").is(':checked')){
                $j(':checkbox').each(function() {
                    this.checked = true;
                })
            } else {
                $j(':checkbox').each(function() {
                    this.checked = false;
                })
            }
        }
    </script>

    <apex:pageBlock>
        <apex:form >        
            <apex:pageBlockSection columns="1">
                <p>
                    <h1>Select options:</h1><br/><br/>
                    <label><input type="checkbox" name="selectAll"/><b>Select all</b></label>

                    <apex:selectCheckboxes value="{!chckValueSelected}" layout="pageDirection">
                        <apex:selectOptions value="{!chckValues}"/>
                    </apex:selectCheckboxes><p/>
                </p>
            </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>

 

   
© Paweł Woźniak