I want to convert picklist and dependent pick list in to two multipick lists in visualforce page for selecting multiple values for searching purpose. When I select multiple values in first multipicklist then dependent multipicklist has to show dependent picklist field values of all selected controlling multipicklist fields.

Can anyone please help me how to achieve this one in visualforce page? Thanks,

  • In Salesforce standard feature multi select picklist can not be a controlling field as per this link . Are you looking for complete Apex and VisualForce coding?
    – Saroj Bera
    Commented Jul 30, 2015 at 10:05
  • Thanks for reply .I'm looking for work around either in javascript or apex
    – Lax_me
    Commented Jul 30, 2015 at 11:55

1 Answer 1


I can only think of this solution below. Here the second picklist values will be autopopulated depend on the selected values on the first picklist. Hope this will help.


public class loadingSpinnerCtrl {
    public List<String> dropdown1{get; set;}
    public List<SelectOption> options;
    public void spin() {
        options = new List<SelectOption>();
        for(String s: dropdown1){
            if(s == '1'){
                options.add(new SelectOption('1','Value 1'));
                options.add(new SelectOption('2','Value 2'));
            }else if(s == '2'){
                options.add(new SelectOption('3','Value 3'));
                options.add(new SelectOption('4','Value 4'));
            }else if(s == '3'){
                options.add(new SelectOption('5','Value 5'));
                options.add(new SelectOption('6','Value 6'));
            }else if(s == '4'){
                options.add(new SelectOption('7','Value 7'));
                options.add(new SelectOption('8','Value 8'));
            }else if(s == '5'){
                options.add(new SelectOption('7','Value 9'));
                options.add(new SelectOption('8','Value 10'));
        long now = datetime.now().gettime();
        while(datetime.now().gettime()-now<2000); // Busy loop for 2000 ms to simulate delay
    public List<SelectOption> getItems() {
        return options;

VF Page

<apex:page controller="loadingSpinnerCtrl">
    <apex:form id="form">    
        <apex:selectList id="selected_list" multiselect="true" value="{!dropdown1}" required="false" size="6">
            <apex:selectOption itemvalue="1" itemLabel="First"/>
            <apex:selectOption itemvalue="2" itemLabel="Second"/>
            <apex:selectOption itemvalue="3" itemLabel="Third"/>
            <apex:selectOption itemvalue="4" itemLabel="Fourth"/>
            <apex:selectOption itemvalue="5" itemLabel="Fifth"/>
            <apex:actionSupport event="onchange" reRender="dropdown2" action="{!spin}" status="status"/>
        <apex:selectList id="dropdown2"  multiselect="true" required="false" size="6">
            <apex:selectOption itemvalue="None" itemLabel="--None--"/>
            <apex:selectOptions value="{!items}" />
        <apex:actionStatus id="status">
            <apex:facet name="start">
                <div>Loading Please wait........</div>
  • @lax-me if it was the answer can you please mark it as answer. Thanks.
    – Saroj Bera
    Commented Aug 4, 2015 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .