Intenté hacer que el botón marque todo y cambiará el valor de la lista de selección para que sea verdadero, después de eso, el valor del botón cambiará para desmarcar todo, pero no funciona. alguien sabe como hacer que funcione? Gracias
este es mi código ahora
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>