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
Suresh Radha 1Suresh Radha 1 

How to access VF page elements from custom button script?

Hi All,

  Need help!!

 I am trying to access VisualForce Page elements(Checkbox) from Case detail Page using Custom button javascript. But document.getElementsByClassName('chkSelected')  does not get recognized. Any help is highly appreciated.. Thanks!! 
☯ BonY ☯☯ BonY ☯
Hi Suresh Radha,

If you want access the DOM  input elements by using class name, you need to use index value.

Suresh Radha 1Suresh Radha 1
Thanks for the repl BoNI. I actually tried below code from custom button in Casedetail Page and it did not help. Any suggestion?

function isSelected(){
  var checkedValue = null;
  var inputElements = document.getElementsByClassName('chkSelected');
  for(var i=0; inputElements[i]; ++i){
           checkedValue = inputElements[i].value;
           return true;
Suresh Radha 1Suresh Radha 1
Some Additional info.
 Below is section of VF page

  <apex:outputPanel layout="block" style="overflow:auto;width:1550px;height:250px" >
            <apex:pageBlockTable value="{!products}" var="c" id="ProductList"  >

                <apex:column >


                    <apex:inputCheckbox value="{!}" styleClass="chkSelected" id="sProd" />


                <apex:column value="{!c.con.Product__c}" />

                <apex:column value="{!c.con.Shipping_Address_Details__c}" />
☯ BonY ☯☯ BonY ☯
Hi Suresh,

Can you say your requirement clearly?