I want to generate dynamic ID in my vf page for columns.

Here is my code:

<apex:repeat value="{!customerMap}" var="indexKey" >
    <apex:pageBlockTable value="{!customerMap[indexKey]}" var="objWrapper">
        <apex:column >  
            <apex:facet name="header">                           
                <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
        <apex:inputCheckbox value="{!objWrapper.selected}" id="inputId"/>       
        <apex:column value="{!objWrapper.custmer.name}" headerValue="{!indexKey}"/>  

I have a javascript which select all check boxes when i checked header check box.But here am Creating table with repeat tag,because of this whenever am clicking header check box it is selecting all the check boxes from all table. I want specific header check box for each table.

as per my knowledge this is because of Column ID which is Unique for all tables. am getting error literal value is required when i try to give dynamic ID.

can anyone pls help me on this,how to make id as dynamic.


2 Answers 2


This would be helpful for you...

<apex:component >

    function cvCheckAllOrNone(allOrNoneCheckbox) {

        // Find parent table
        var container = allOrNoneCheckbox;
        while (container.tagName != "TABLE") {
            container = container.parentNode;

        // Switch all checkboxes
        var inputs = container.getElementsByTagName("input");
        var checked = allOrNoneCheckbox.checked;
        for (var i = 0; i < inputs.length; i++) { 
            var input = inputs.item(i);
            if (input.type == "checkbox") {
                if (input != allOrNoneCheckbox) {
                    input.checked = checked;

    <apex:inputCheckbox onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>


Use this component in column header and use it as master checkbox..

<apex:column >
    <apex:facet name="header">
        <c:CheckAllOrNone />
    <apex:inputCheckbox value="{!mem.checked}"/>

Refer from : master check box to select all records


Given that you want to select a group of checkboxes you shouldn't be using an ID anyway since an ID should be specific to a single element.

You could create your header checkbox like this:

<apex:inputCheckbox onclick="selectAllCheckboxes(this,'{!indexKey}')"/>

And then change the others to use class:

<apex:inputCheckbox value="{!objWrapper.selected}" styleClass="{!indexKey}"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .