Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Set CommandButton Value on Javascript - salesforce

I tried to make button checkall and it will change value of selectlist to be true, after that, the value of button will be changed to uncheckall, but its not works. anyone know how to make it works? thanks

this is my code now

function toggleCheck() {
      var btn = document.getElementsByClassName("toggle_check")[0];
      var checkboxes = document.getElementsByTagName("input");
      alert('Btn '+ btn.value);
      console.log('Test Btn ' + btn.value);
      if (btn.value === "check all") {
        for (var i = 0; i < checkboxes.length; i++) {
          var check= document.getElementsByClassName("checkOpex")[i].value = 'True';
        }
        btn.value = 'uncheck all';
      } else {
        for (var j = 0; j < checkboxes.length; j++) {
          var check= document.getElementsByClassName("checkOpex")[i].value = 'False';
        }
        btn.value = 'uncheck all';
      }
}

<apex:column headerValue="Action" >
                    <apex:facet name="header">
                        <apex:commandButton styleClass="toggle_check" onclick="toggleCheck()" value="check all">
                            <apex:actionSupport event="onchange"/>
                        </apex:commandButton>
                    </apex:facet>
                    <apex:selectList id="inputId" value="{!acc.Opex__c}" styleClass="checkOpex" size="1">
                        <apex:selectOption itemValue="True" itemLabel="Checked" />
                        <apex:selectOption itemValue="False" itemLabel="Unchecked"/>
                        <apex:actionSupport event="onchange"/>
                    </apex:selectList>
                </apex:column>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!