+ Start a Discussion
Vamsi VaddipalliVamsi Vaddipalli 

How to display pageblocksection on selecting a value from the picklist using rendered?

i am new to salesforce i want to creat an visualforce page  to display pageblocksection on selecting a value from the picklist using rendered.
But when i am selecting Energy value in pickList it is not showing NoofEmployees field.

Can you people please guide me

<apex:page standardController="Account" extensions="HidePageBlock">
    <apex:form >
    <apex:pageBlock title="Industry">
        <apex:pageBlockSection title="Options">
            <apex:inputField value="{!Account.Industry}"/>
            <actionsupport event='onchange' rerender='in1'/>
                    <apex:pageBlockSection title="Result" id="in1" rendered="{!IF(Account.Industry == 'Energy',true,false)}">
                        <apex:inputField value="{!Account.NumberOfEmployees}" />

Contoller Extension:
public class HidePageBlock {
    public HidePageBlock(ApexPages.StandardController controller)


Thanks and Regards
Khan AnasKhan Anas (Salesforce Developers) 
Hi Vamsi,

Greetings to you!

Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.

<apex:page standardController="Contact" extensions="HideSectionBasedOnPicklistC">
    <apex:form >
        <apex:pageBlock > 
            <apex:actionRegion >
                <apex:selectList value="{!pickchoice}" multiselect="false" size="1">
                    <apex:selectOptions value="{!items}"/>
                    <apex:actionSupport event="onchange" rerender="out1,out2"/>
            <apex:pageBlockSection id="out1" >
                <apex:outputPanel rendered="{!IF(pickchoice== 'NRI' && pickchoice!= 'None', true , false)}">                    
                    <apex:outputLabel value="First Name" /><br/>
                    <apex:inputField value="{!contact.FirstName}" /><br/><br/>
                    <apex:outputLabel value="Last Name" /><br/>
                    <apex:inputField value="{!contact.LastName}" />
            <apex:pageBlockSection id="out2" >
                <apex:outputPanel rendered="{!IF(pickchoice== 'Non-NRI' && pickchoice!= 'None', true , false)}">
                    <apex:outputLabel value="Email" /><br/>
                    <apex:inputField value="{!contact.Email}" /><br/><br/>
                    <apex:outputLabel value="Phone" /><br/>
                    <apex:inputField value="{!contact.Phone}" />

public class HideSectionBasedOnPicklistC {
    public String Pickchoice {get;set;}
     public HideSectionBasedOnPicklistC(ApexPages.StandardController controller) {

    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','None'));
        options.add(new SelectOption('NRI','NRI'));
        options.add(new SelectOption('Non-NRI','Non-NRI'));
        return options;

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas