function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AniltAnilt 

Unable to save multi-picklist values in the record

Hi all,

 

I've written code in which multi-picklist values has to save in the record. Can you please modify my code in such a way that it must save the values in the record

 

VisualForcePage Code:

 

<apex:page standardController="Registration__c" extensions="checkbox">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!Save}" value="Save"/>
<apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputtext value="{!Registration__c.Name}"/>
<apex:selectCheckboxes value="{!countries}">
<apex:selectOptions value="{!items}"/>
</apex:selectCheckboxes><br/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Apex Code:

 

public class checkbox {
registration__c reg {get; set;}
String[] countries = new String[]{};
String java{get; set;}
public String[] getCountries() {
return countries;
}

public void setCountries(String[] countries) {
this.countries = countries;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Java','Java'));
options.add(new SelectOption('php','php'));
options.add(new SelectOption('.net','.net'));
return options;
}
public checkbox(ApexPages.StandardController controller) {
}

}