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
prazonprazon 

Urgent help:peculiar error vf page element cannot access javascript function

Hi,

 

I have the following javascript function to be accessed from apex:checkbox but the method is not getting invoked at all I am not getting the alert..Can somebody say is there any error?

 

 <script type="text/javascript">
       function SetSel(elem)
            {
              alert("Hi");
              var elems = document.getElementsByTagName("{!$Component.theForm.theListBlock.productBlock.selectLine1}");
              var currentState = elem.checked;
              var elemsLength = elems.length;
            
              for(i=0; i<elemsLength; i++)
              {
                if(elems[i].type === "checkbox")
                {
                   elems[i].checked = false;   
                }
              }
            
              elem.checked = currentState;
            }​
   
   </script>



...................

 <apex:outputPanel id="theListBlock">
    <apex:pageBlock mode="edit" id="productBlock">
        <apex:panelGrid cellpadding="2" cellspacing="2" columns="2" width="100%" bgcolor="#E1E6EE">
            <apex:outputPanel >
            <apex:image value="{!URLFOR($Resource.bz,'icons/product.png')}" height="30"/>
            <apex:outputText value="Select Deal Category" styleclass="header"/>
            </apex:outputPanel>
        </apex:panelGrid>
        <apex:pageBlockTable value="{!PWlist}" var="p" rules="cols" rows="50" >
            <apex:column width="25">
            
            
            <apex:inputCheckbox value="{!p.checked}" id="selectLine1" onclick="SetSel(this)"/>
            </apex:column>
            <apex:column headerValue="Deal Category">
                <apex:outputField value="{!p.product.name}"/>
            </apex:column>        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:outputPanel>







....................

 

Venkat_rdVenkat_rd

try with <apex:actionsupport> with onchange parameter if you need to call javascript if the user tries to change.