I would like to check at least one user is selected(checkbox checked) when clicking on Send Email button. How to have a conditional logic in the Command button?
<apex:pageBlockTable value="{!contacts}" var="c" id="table">
<apex:column >
<apex:inputCheckbox value="{!c.selected}" id="checked"/>
</apex:column>
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
<apex:pageBlockSection >
<apex:commandButton value="Send Email" action="{!sendEmail}" onclick="if(!confirm('Do you want to send the email?')){return false;}" onComplete="window.top.location.reload()"/>
</apex:pageBlockSection>
Solution trying: Sending email to the select contact records. The above pageBlockTable will display all the contact records with provided SOQL query. Implemented using Wrapper class to display contact records with checkboxes.
Now I am trying to validate whether the end user selected(checkboxes) at least one of the listed contacts before executing the sendEmail action. How can I approach that?