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

how to design multipicklist in visual force page?

how to design multipicklist in visual force page?i mean to say through apex code how to implement multipicklist with using customization.if is it possible.pls clarify this.if any avail of code for these pls give me.thanks in advance.




Try the below code snippet as reference:


----------- vf page----------------

<apex:page controller="examples52" >


<apex:form >


<apex:selectList id="mp1" value="{!countries}" multiselect="true" onclick="SelectAllCountry();" > Channel :

<apex:selectOptions rendered="true" value="{!items}"/>


<apex:commandButton value="Test" action="{!test}" rerender="out" status="status"  />


<apex:outputPanel id="out">

<apex:actionstatus id="status" startText="testing...">

<apex:facet name="stop">

<apex:outputPanel >

<p>You have selected:</p>

<apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>








function SelectAllCountry() {


var multi = document.getElementById("mp1").index;


for (i = 0; i < multi.options.length; i++)

multi.options[i].selected = true;





-------------- apex controller----------------


public class examples52 {


String[] countries = new String[]{};


public PageReference test() {

return null;



public List<SelectOption> getItems() {

List<SelectOption> options = new List<SelectOption>();

options.add(new SelectOption('Americas','Americas'));

options.add(new SelectOption('AP','AP'));

options.add(new SelectOption('EMEA','EMEA'));

return options;



public String[] getCountries() {

return countries;



public void setCountries(String[] countries) {

this.countries = countries;




Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.