Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- How to Pass selected Checkbox values from visualfo...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-08-2012 11:54 PM
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>
Solved! Go to Solution.
Re: How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-09-2012 02:58 AM
Hi
The value of checkbox is always true or false...I think you want to save label of checkbox...am I correct.....?
Thanks
Re: How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-09-2012 03:04 AM
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.
Re: How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-09-2012 03:48 AM
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
<apex:inputCheckbox label="Newyork" value = "{!NY}"/>
<apex:inputCheckbox label="Washington" value = "{!W}"/>
//In the Class
String total;
if(NY == True){
total = total+ 'NewYork';
}
if(W == True){
total = total + 'Washington';
}
c.PlacesVisisted__c = total;
Update c;
Re: How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-09-2012 05:53 AM
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 :)
Re: How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-11-2012 09:36 PM
Hi
Try this.....
Here is my page
<apex:page standardController="Contact" extensions="FStoringCheckBoxValueExtension">
<apex:form >
<apex:pageBlock title="Update Contact Details">
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!savingCheckBoxValue}" 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:inputField value="{!Contact.LastName}"/>-->
<p> Last Name: <apex:inputText value="{!lastname}"/></p>
</apex:pageBlockSection>
<apex:outputPanel id="IndiaBlock">
<apex:pageBlockSection rendered="{!Contact.Country__c == 'India'}" id="SampleSendInfoBlock" title="Select Places Visited">
<apex:outputLabel value="Agra" for="indiacheck">
<apex:inputCheckbox value="{!Indiaplaceist}" id="indiacheck1">
<apex:actionSupport event="onclick" action="{!getSelected}" rerender="IndiaBlock"/>
</apex:inputCheckbox>
</apex:outputLabel>
<apex:outputLabel value="Delhi" for="indiacheck2">
<apex:inputcheckbox id="indiacheck2" value="{!Indiaplace2nd}">
<apex:actionSupport event="onclick" action="{!getSelected}" rerender="IndiaBlock"/>
</apex:inputCheckbox>
</apex:outputLabel>
</apex:pageBlockSection>
</apex:outputPanel>
<apex:outputPanel id="USBlock">
<apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'America'}" id="USPageBlock">
<apex:outputLabel value="Newyork" for="Newyorkcheck1">
<apex:inputCheckbox value="{!Newyorkplaceist}" id="Newyorkcheck1">
<apex:actionSupport event="onclick" action="{!getSelected}" rerender="IndiaBlock"/>
</apex:inputCheckbox>
</apex:outputLabel>
<apex:outputLabel value="Washington" for="Newyorkcheck2">
<apex:inputCheckbox value="{!Newyorkplace2nd}">
<apex:actionSupport event="onclick" action="{!getSelected}" rerender="IndiaBlock"/>
</apex:inputCheckbox>
</apex:outputLabel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>My class is...
public class FStoringCheckBoxValueExtension {
private Contact contact;
public String Indiaplaceist{get;set;}
public String lastname{get;set;}
public String Indiaplace2nd{get;set;}
public String Newyorkplaceist{get;set;}
public String Newyorkplace2nd{get;set;}
public String resultString{get;set;}
public FStoringCheckBoxValueExtension(ApexPages.StandardC ontroller controller) {
Contact contact = new Contact();
}
public void savingCheckBoxValue()
{
//upsert acct;
//System.debug('@@@@@@@@@@@@@@@@@@@Indiaplace@@@@@ @@@@@'+Indiaplace);
System.debug('@@@@@@@@@@@@@@@@@@@resultString @@@@@@@@@@'+resultString );
Contact contact = new Contact();
contact.PlacesVisisted__c = resultString ;
contact.LastName= lastname;
insert contact;
}
public PageReference getSelected(){
System.debug('@@@@@@@@@@@@@@@@@@@Indiaplace@@@@@@@ @@@'+Indiaplaceist);
if(Indiaplaceist == 'true'){
if(resultString !=null){
resultString = resultString+' '+ 'Agra';
}
else{
resultString = 'Agra';
}
System.debug('@@@@@@@@@@@@@@@@@@@resultStringtestI f @@@@@@@@@@'+resultString );
}
else if(Indiaplace2nd == 'true'){
if(resultString !=null){
resultString = resultString+' '+'Delhi' ;
}
else{
resultString = 'Delhi' ;
}
}
else if(Newyorkplaceist == 'true') {
if(resultString !=null){
resultString = resultString+' '+'Newyork' ;
}
else{
resultString = 'Newyork' ;
}
}
else if(Newyorkplace2nd == 'true') {
if(resultString !=null){
resultString = resultString+' '+'Washington';
}
else{
resultString = 'Washington';
}
}
else{
}
return null;
}
}Did this post answers your questions if so please mark it solved so that others get benifited..
Thanks
Re: How to Pass selected Checkbox values from visualforc e page to a TextArea Field in an Object.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-11-2012 11:10 PM
Thanks a lot Asish.. Got the solution and doing few changes for my requirment.. Thanks for your time.

