You need to sign in to do that
Don't have an account?
How to Pass selected Checkbox values from visualforce page to a TextArea Field in an Object.
Hi,
Please help me with the below scenario, I have Visualforce page through which I can select a value from Picklist and based on the Picklist value particular Checkboxes will be displayed on the page. My Requirment is when a checkbox value is selected and Save botton is clicked, then the checkbox value need to be stored in a TextArea Field in the respective Object.
Selected Checkbox values should be displayed in a TextArea Field ' PlacesVisisted__c ' in the Contact Object.
Please help me on this scenario. ThankYou.
Below is my Visualforce Page.
<apex:page standardController="Contact"> <apex:form > <apex:pageBlock title="Update Contact Details"> <apex:pageBlockButtons location="bottom"> <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageBlockSection id="NewPage" title="Select The Country"> <apex:inputField value="{!Contact.Country__c}"> <apex:actionSupport event="onchange" reRender="IndiaBlock, USBlock, ChinaBlock, AusesBlock"/> </apex:inputField> <apex:inputText value="{!Contact.Name}"/> </apex:pageBlockSection> <apex:outputPanel id="IndiaBlock"> <apex:pageBlockSection rendered="{!Contact.Country__c == 'India'}" id="SampleSendInfoBlock" title="Select Places Visited"> <apex:inputCheckbox label="Agra"/> <apex:inputcheckbox label="Delhi"/> </apex:pageBlockSection> </apex:outputPanel> <apex:outputPanel id="USBlock"> <apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'America'}" id="USPageBlock"> <apex:inputCheckbox label="Newyork"/> <apex:inputCheckbox label="Washington"/> </apex:pageBlockSection> </apex:outputPanel> <apex:outputPanel id="ChinaBlock"> <apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'China'}" id="ChinaPageBlock"> <apex:inputCheckbox label="Bejing"/> <apex:inputCheckbox label="Taiwan"/> </apex:pageBlockSection> </apex:outputPanel> <apex:outputPanel id="AusesBlock"> <apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'Australia'}" id="AusesPageBlock"> <apex:inputCheckbox label="Sydney"/> <apex:inputCheckbox label="Canberra"/> </apex:pageBlockSection> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>
Hi
Try this.....
Here is my page
My class is...
Did this post answers your questions if so please mark it solved so that others get benifited..
Thanks
All Answers
Hi
The value of checkbox is always true or false...I think you want to save label of checkbox...am I correct.....?
Thanks
Hi Asish,
thanks for the reply.
The value of the checkbox is False by default, when we select particular Checkbox then that repsective label has to be sent to Custom TextArea Field ( Places_Visted__c) in Contact Object. Is there any possible way for this.
You would need to bind all the check boxes with some variable in your controller. Then check which all variables are true in the Class and those which are true just add them in a string field and update the contact record.
I would suggest to use a picklist multi select to do this instead, as it would be easier to maintain
Hi Rasesh,
Thanks for the Reply.
If you dont mind could you please help me out by showing how I can bind a checkbox to variable. because in this case i'm creating a checkbox in the page. there is no instance of the checkbox in the object.
if possible could you please take one checkbox and give me the code. I'll try to understand based on that. Thank You so much.
btw your name says u work for TCS. I'm also working for TCS. nice to meet you :)
Hi
Try this.....
Here is my page
My class is...
Did this post answers your questions if so please mark it solved so that others get benifited..
Thanks
Thanks a lot Asish.. Got the solution and doing few changes for my requirment.. Thanks for your time.
Please help...!!!!. I want to show the selected checkbox item on another visualforce page.Please view my code. The link is:
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BF3YIAW
I have a similar requirement currently. I want to store the labels of selected fields in a text area field. How you achieved this? Can you please help ?
Thanks & Regards,
Amita Tatar