You need to sign in to do that
Don't have an account?
check all inputfield checkboxes with one click
Hi there!
I'm very new to visualforce / apex and there's one thing I can't get to work:
I have a simple vf page with two columns of checkboxes and I have to create a button which once being clicked ticks all the checkboxes from unchecked to checked or vise versa.
This is my current code:
<apex:page standardController="Rahmenvertrag_OptIn__c" recordSetVar="rv" standardStylesheets="true">
<div class="container1">
<apex:pageBlock >
<h1>Rahmenvertrag Teilnehmer-Liste</h1>
<apex:form id="form1">
<apex:pageBlockTable value="{! rv }" var="rvt" id="table1">
<apex:column value="{! rvt.KD_TN_EKP__c}" headerClass="tableheader" headerValue="EKP"/>
<apex:column value="{! rvt.KD_TN_Name__c}" headerClass="tableheader" headerValue="Rahmenvertrag Teilnehmer"/>
<apex:column value="{! rvt.KD_TN_Adresse__c}" headerClass="tableheader" headerValue="Adresse"/>
<apex:column>
<apex:facet name="header"><span class="tableheader">Einwilligung<br/>Datenaustausch</span></apex:facet>
<apex:inputCheckbox value="{! rvt.Datenaustausch__c}" />
</apex:column>
<apex:column >
<apex:facet name="header"><span class="tableheader">Einwilligung<br/>Werbliche Ansprache</span></apex:facet>
<apex:inputField value="{! rvt.Werbeansprache__c}" />
</apex:column>
</apex:pageBlockTable>
<br/>
<table>
<tr>
<td ><apex:commandButton action="{!save}" value="Zwischenspeichern"/></td>
<td><apex:commandButton action="{!save}" value="Änderungen bestätigen" /></td>
</tr>
</table>
</apex:form>
</apex:pageBlock>
</div>
</apex:page>
Any help would be much appreciated!
Thanks in advance
I hope you are doing well .....!!
Please use the below code just copy and paste in your org and see the functionality and change according to your requirement:
Hope this helps you.
If this helps kindly mark it as BEST ANSWER so that it may help others in the future.
Thanks & Regards,
Foram Rana
All Answers
I hope you are doing well .....!!
Please use the below code just copy and paste in your org and see the functionality and change according to your requirement:
Hope this helps you.
If this helps kindly mark it as BEST ANSWER so that it may help others in the future.
Thanks & Regards,
Foram Rana
thanks for your help, it is really appreciated.
In general your code does work but I can't get it to work with my <apex:inputCheckbox> elements.
For those elements the attribute type name is not supported so I gave them the id="rowSelectCheckBox".
But the javascript seems like it can't find the checkboxes or something else won't work.
You can find attached my whole code as it is right now. It would be really nice if you could work off of that and help me get this thing to work!
Thanks from germany :)
with "var checkboxes = document.getElementsByTagName("input");".
Thanks!