[SalesForce] ActionSupport rerender not working

I want to render Account.Type and Account.Industry when Account.Rating ='Hot'

  <apex:page standardController="Account">
  <apex:form >
  <apex:pageBlock title="Account Edit" id="pb">
  <apex:pageblockSection title="Account Information" collapsible="false" columns="2" id="pbs1">
   <apex:inputField value="{!Account.Name}"/>
   <apex:inputField value="{!Account.Rating}">
   <apex:actionSupport event="onchange" rerender="op1"/>  
   </apex:inputField>
    <apex:outputPanel id="op1"  layout="none"> 
   <apex:outputPanel rendered="{If(!Account.Rating == 'Hot',true,false)}" id="op2">
   <apex:inputField value="{!Account.Type}"/>
   <apex:inputField value="{!Account.Industry}"/>
   </apex:outputPanel> 
   </apex:outputPanel> 
  </apex:pageblockSection>
  <apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
  <apex:commandButton action="{!Cancel}" value="Cancel"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
 </apex:form> 
</apex:page>

Best Answer

There were two problems: You need to wrap rating in actionRegion since Account name is mandatory. Also you have placed ! at wrong place in redered condition. I have made corrections. Please check below code snippet.

<apex:page standardController="Account">
  <apex:form >
  <apex:pageBlock title="Account Edit" id="pb">
  <apex:pageblockSection title="Account Information" collapsible="false" columns="2" id="pbs1">
   <apex:inputField value="{!Account.Name}"/>
   <apex:actionRegion>
       <apex:inputField value="{!Account.Rating}">
       <apex:actionSupport event="onchange" action="{!null}" rerender="op1"/>  
       </apex:inputField>
   </apex:actionRegion>
    <apex:outputPanel id="op1" > 
       <apex:outputPanel rendered="{!If(Account.Rating == 'Hot',true,false)}" id="op2">
           <apex:inputField value="{!Account.Type}"/>
           <apex:inputField value="{!Account.Industry}"/>
       </apex:outputPanel> 
   </apex:outputPanel> 
  </apex:pageblockSection>
  <apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
  <apex:commandButton action="{!Cancel}" value="Cancel"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
 </apex:form> 
</apex:page>

Before changing rating: enter image description here After changing rating to Hot: enter image description here I hope this helps you.

Related Topic