top of page

Show fields based on what the user selects on a multi-select picklist.

I know if you're familiar with Visualforce the first thing that comes in your mind is to use the 'CONTAINS' function, which is true, but you need more. You need to use 2 arguments joined by an 'OR' to control the behaviour to ensure that the field is not rendered when the page loads.

Click Option 2 Here for the Demo: and select Yellow and Blue.

<apex:page standardController="Client__c" showHeader="false" sidebar="false">

<apex:form >

<apex:pageblock >

<apex:pageBlockSection title="Pick your favourite colors" columns="1">

<apex:outputPanel id="p1">

<apex:inputField value="{!Client__c.Fav_colors__c}"><apex:actionSupport event="onchange" rerender="p1"/></apex:inputField>

<apex:inputField value="{!Client__c.Reason_You_Love_Yellow__c}" html-placeholder="Reason you love Yellow" rendered="{!(Contains(Client__c.X3_fav_colors__c, 'Yellow'))||(ISBLANK('Yellow'))}" /> <p></p>

<apex:inputField value="{!Client__c.Reason_You_Love_Blue__c}" html-placeholder="Reason you love Blue" rendered="{!(Contains(Client__c.X3_fav_colors__c, 'Blue'))||(ISBLANK('Blue'))}" />

</apex:outputPanel>

</apex:pageBlockSection>

</apex:pageblock>

</apex:form>

</apex:page>

On the code above, fields Reason_You_Love_Yellow__c and Reason_You_Love_Blue__c are only showed if the user selects them. If the user de-selects them, they disappear.

Featured Posts
Recent Posts
Archive
Search By Tags
No tags yet.
Follow Me
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page