0

I want to render page block1 when x value is selected in dynamic picklist, render page block 2 when y value is selected in dynamic picklist in VF page. How to do it?

<apex:selectList value="{!selecteduser1}" multiselect="false" size="1">
                <apex:selectOption itemValue="User" itemLabel="User" id="u1" />    
                <apex:selectOption itemValue="Queue" itemLabel="Queue" id="u2" />
          
            </apex:selectList>
           
         <apex:pageBlock id="pb1" >
</apex:pageBlock>
   <apex:pageBlock id="pb2" >
</apex:pageBlock>

2 Answers 2

0

We can use rendered attribute for that -

<apex:selectList value="{!selecteduser1}" multiselect="false" size="1">
            <apex:selectOption itemValue="User" itemLabel="User" id="u1" />    
            <apex:selectOption itemValue="Queue" itemLabel="Queue" id="u2" />
      
        </apex:selectList>
       
     <apex:pageBlock id="pb1" rendered="{!selecteduser1 == 'User'}">
     </apex:pageBlock>
    <apex:pageBlock id="pb2" rendered="{!selecteduser1 == 'Queue'}" >
   </apex:pageBlock>
2
  • Hi Darksh, I have added rendered attribute, now nothing is coming. I mean no block is appearing now. Do I need to change something?
    – user115525
    Commented Nov 10, 2022 at 8:02
  • Give deafult value to this selecteduser1 Commented Nov 10, 2022 at 8:09
0
  1. Use the rendered attribute on the pageBlock tag

  2. Check if the picklist value is empty or populated in the rendered tag

  3. If populated display the pageBlock 1

  4. Do the same for picklist2 as well

    <apex:pageBlock rendered="{!selecteduser1 == 'User'}" > </apex:outputPanel> <apex:pageBlock id="pb2" rendered="{!selecteduser1 == 'Queue'}" > </apex:pageBlock>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .