You need to sign in to do that
Don't have an account?

Selectable checkbox in table in custom visualforce page?
I have a VF page that searches for contacts using the first name and mailing state of the contact. It then returns a list of contacts on that same page that match the search. I would like to be able to select a checkbox next to the returned records and be able to update the mailing state for all of the selected records. Here is what I have:
Any help is appreciated. Thanks!
<apex:page controller="searchContacts_Controller"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons location="top"> <apex:commandButton value="Search" action="{!searchContacts}" reRender="contact-table" /> </apex:pageBlockButtons> <apex:pageBlockSection id="contact-table" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="FirstName" /> <apex:inputText value="{!Firstname}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Mailing State" /> <apex:inputText value="{!mailingState}" /> </apex:pageBlockSectionItem> <apex:pageBlockTable value="{!contacts}" var="c"> <apex:column > <apex:facet name="header">Name</apex:facet> {!c.FirstName} </apex:column> <apex:column > <apex:facet name="header">Mailing State</apex:facet> {!c.MailingState} </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class searchContacts_Controller { public List<Contact> contacts { get; set; } public String Firstname { get; set; } public String mailingState { get; set; } public applyPayments_Controller() { contacts = new List<Contact>(); } public PageReference searchContacts() { contacts = [select Id ,FirstName ,MailingState from Contact where FirstName = :Firstname and MailingState = :mailingState]; return null; } }
Any help is appreciated. Thanks!
I understand your requirement, you are almost reached. try this below code it may helps you.
Please let me know if it's help you.
Thanks & Regards.
Madhukar_Heptarc