function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mohmad Sohel 2Mohmad Sohel 2 

visualforce reRender

Hi Guys,
I have wrote a vf page which is used to display input fields based on LeadSource. If LeadSource == 'web' then it should dispaly Description. But below code is not working..
Help me regarding this. Thank You

<apex:page standardController="Contact">
    <apex:form >
        <apex:pageBlock title="Enter Contact Information">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!Save}" />
            
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Contact.LastName}" />
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Lead Source"/>
                    <apex:actionRegion >
                    <apex:inputField value="{!Contact.LeadSource}" >
                        <apex:actionSupport event="onChange" reRender="ajaxrequest" />
                        </apex:inputField>
                    </apex:actionRegion>
               
                </apex:pageBlockSectionItem>
            
            </apex:pageBlockSection>
        
            <apex:outputPanel id="ajaxrequest">
                <apex:pageBlockSection rendered="{!Contact.LeadSource=='Web'}">
                    <apex:inputField value="{!Contact.Description}"/>
  
                </apex:pageBlockSection>
                <apex:pageBlockSection rendered="{!Contact.LeadSource=='Phone Inquiry'}">
                <apex:inputField value="{!Contact.Phone}"/>
                   </apex:pageBlockSection>
                </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Best Answer chosen by Mohmad Sohel 2
Vishal Negandhi 16Vishal Negandhi 16
I know this. Faced it a couple of times earlier. 

Just change this
<apex:actionSupport event="onchange" reRender="ajaxrequest" />

event as "onChange" doesn't work but if you keep it to "onchange", you should be able to make it work. Worked for me always!

Hope this helps :)

All Answers

Vishal Negandhi 16Vishal Negandhi 16
I know this. Faced it a couple of times earlier. 

Just change this
<apex:actionSupport event="onchange" reRender="ajaxrequest" />

event as "onChange" doesn't work but if you keep it to "onchange", you should be able to make it work. Worked for me always!

Hope this helps :)
This was selected as the best answer
Kapil KaushikKapil Kaushik
Hi  Mohmad Sohel,

You should give Id of the PageBlockSection where you have given the rendered Condition.
I think that will work.

Please reply on this post.
 
Mohmad Sohel 2Mohmad Sohel 2
Thank You Vishal and Kapil