Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
<!-- Page: --> <apex:page controller="sampleCon"> <apex:form> <apex:selectList value="{!countries}" multiselect="true"> <apex:selectOptions value="{!items1}"/> </apex:selectList><p/> <apex:selectList value="{!countries2}" multiselect="true"> <apex:selectOptions value="{!items2}"/> </apex:selectList><p/> <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/> </apex:form> <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> </apex:outputPanel> </apex:facet> </apex:actionstatus> </apex:outputPanel> </apex:page> /*** Controller: ***/ public class sampleCon { String[] countries1 = new String[]{}; String[] countries2 = new String[]{}; public PageReference test() { //Here based upon your logic Now you have 2 selectoption list. you can manipulate it however you want it. Items1.addAll(Items2); return null; } public List<SelectOption> getItems1() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; } public List<SelectOption> getItems2() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; } public String[] getCountries() { return countries; } public void setCountries(String[] countries) { this.countries = countries; } }
You want to do it through VF page or on Record detail page .
If it is VF page then how do you refer your picklist
1. inputField
2. selectOption
In 2nd case you can manipulate using selectOption class methods.
If it is on detail page ,then you can use Apex trigger .
BTW Could you explain business case for same ?
Please check below link it may solve your problem .
https://hisrinu.wordpress.com/2011/05/30/custom-multi-select-picklist-field-in-visualforce/
Please try below code. This code is not compiled and can be used to understand selection manipulation.
Let us know if it helps you.