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>