You need to sign in to do that
Don't have an account?
DeveloperSud
How to create two mutually dependent custom picklist in visualforce ?
Hi Guys,
I am working on a new topic where I need to create two mutually dependent picklist in a VFpage using same method used as actionsupport action.The situation is like there will be two picklist and a button to show the last selected value from the picklists. Two picklist will have same value and change in one's value will automatically change other's value too. While implementing it, the issue I am facing is :only the last picklist is controlling the situation means the value selected in the last picklist is displaying only .I am giving the sample code and look of the page.Kindly give me your advise how I can implement it using the same method so that the value change in one picklist will have a change on the other also.
I am working on a new topic where I need to create two mutually dependent picklist in a VFpage using same method used as actionsupport action.The situation is like there will be two picklist and a button to show the last selected value from the picklists. Two picklist will have same value and change in one's value will automatically change other's value too. While implementing it, the issue I am facing is :only the last picklist is controlling the situation means the value selected in the last picklist is displaying only .I am giving the sample code and look of the page.Kindly give me your advise how I can implement it using the same method so that the value change in one picklist will have a change on the other also.
<apex:page controller="exampleCon1x"> <apex:form > <apex:outputPanel id="one11"> <apex:selectList id="piclist1" value="{!selectedRecord}" > <apex:selectOption itemvalue="10" itemLabel="10"/> <apex:selectOption itemvalue="20" itemLabel="20"/> <apex:selectOption itemvalue="50" itemLabel="50"/> <apex:selectOption itemvalue="100" itemLabel="100"/> <apex:actionSupport event="onchange" action="{!search}" reRender="one11"/> </apex:selectList><p/> </apex:outputPanel> <apex:outputPanel id="two22"> <apex:selectList id="picklist2" value="{!selectedRecord}" > <apex:selectOption itemvalue="10" itemLabel="10"/> <apex:selectOption itemvalue="20" itemLabel="20"/> <apex:selectOption itemvalue="50" itemLabel="50"/> <apex:selectOption itemvalue="100" itemLabel="100"/> <apex:actionSupport event="onchange" action="{!search}" rerender="two22"/> </apex:selectList><p/> </apex:outputPanel> <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="{!selectedRecord}" var="s">{!s}</apex:dataList> </apex:outputPanel> </apex:facet> </apex:actionstatus> </apex:outputPanel> </apex:form> </apex:page>
public class exampleCon1x{ public String selectedRecord{get; set;} public Pagereference Search() { return null; } public pageReference test(){ return null; } }
1) http://www.infallibletechie.com/2012/10/dependent-picklist-using-apex-in.html
Apex class
Let us know if this will help you
I checked your code ,It is not my requirement . Here in your code state is controlling picklist and city is dependent to it but my requiremnt is if I change in pickist A as '20' ,picklist B should change to '20' and if I change picklist B to '50',picklist A should also be changed to '50'.I hope the requiremnt is clear now.Thanks for your help.
NOTE:- you can change the Variable name
You have made the city picklist dependent to state picklist , change in State is changing the value in City but reverse is not possible with your code .