You need to sign in to do that
Don't have an account?
Joe Hayes
ReRender Picklist via apex controller
I have a vf page with 2 picklists.
I need the second picklist to update when the first one changes. Rather than using selectOption for the second picklist I want to pass through the field name to rerender so that I can update the values without having to update the controller.
For this I though about using the following:
I have 3 picklist fields (a,b & c) on the custom object (del) but I want picklist1 to select which picklist (a,b or c) depending.
Hope this makes sense.
I need the second picklist to update when the first one changes. Rather than using selectOption for the second picklist I want to pass through the field name to rerender so that I can update the values without having to update the controller.
For this I though about using the following:
<apex:column headerValue="Picklist1"> <apex:selectList value="{!Picklist1}" multiselect="false" size="1"> <apex:selectOption itemValue="a" itemLabel="a"/> <apex:selectOption itemValue="b" itemLabel="b"/> <apex:selectOption itemValue="c" itemLabel="c"/> <apex:actionSupport event="onchange" reRender="b"/> </apex:selectList> </apex:column> <apex:column headerValue="Picklist2"> <apex:inputField value="{!Picklist2}" id="b"></apex:inputField> </apex:column>
Public String Picklist1{get;set;} Public String Picklist2 {get;set;} { if(Picklist1 == 'a'){ Picklist2 = 'del.a__c'; } else if (Picklist1 == 'b'){ Picklist2 = 'del.b__c'; }else if (Picklist1 == 'c'){ Picklist2 = 'del.c__c'; }else { Picklist2 = null; } }
I have 3 picklist fields (a,b & c) on the custom object (del) but I want picklist1 to select which picklist (a,b or c) depending.
Hope this makes sense.
<apex:actionSupport event="onchange" reRender="b" action="{!ChangePicklist}"/>
Please check below post for same issue
1) http://www.infallibletechie.com/2012/10/dependent-picklist-using-apex-in.html
Let us know if this will help you
All Answers
<apex:actionSupport event="onchange" reRender="b" action="{!ChangePicklist}"/>
Please check below post for same issue
1) http://www.infallibletechie.com/2012/10/dependent-picklist-using-apex-in.html
Let us know if this will help you
I had previously seen that link but cannot seem to get it to work, I receive an error "Could not resolve the entity from <apex:inputField> value binding '{!Picklist2}'.
I can't seem to work it out.