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
maheshep.ax379maheshep.ax379 

JavaScript Problem

<script>
    function chkDeleteFn(objCbMaster)
    {
               alert(document.getElementById(objCbMaster).checked);
    }
</script>
<apex:pageBlockTable value="{!contacts}" var="contact"   styleClass="tableClass">
    <apex:column>
        <apex:facet name="header">
            <apex:inputCheckbox id="idMasterCheck" />
        </apex:facet>
        <apex:inputCheckbox id="idCheck" value="{!contact.selectContact__c}"     onclick="chkDeleteFn('{!$Component.idMasterCheck}');"/>
    </apex:column>
</apex:pageBlockTable>


The javascript only triggers only for the first row of the table generated.
can anyone help me??? thanks in advance...
XactiumBenXactiumBen
It's because you're passing in {!$Component.idMasterCheck}, but since it is inside a pageBlockTable it is actually passing in the following id for each row:

:0:idMasterCheck
:1:idMasterCheck
etc.

Since idMasterCheck is in a facet, there's only one of them so it can't find :1:idMasterCheck etc.  If you do alert(objCbMaster); in your javascript function, then copy the id from the alert box you can paste it in the parameters for the onclick event.  That should fix the problem.



Message Edited by XactiumBen on 07-22-2008 06:42 AM