Wednesday, 1 February 2017





Display Section Based on selected picklist value in visualforce salesforce


if you want to display and hide section based on picklist value ? then check the below code

<apex:page standardController="lead" id="pg1">
    <script>
        function hidesection()
        {
           var a = document.getElementById('{!$Component.pg1.form1.status1}').value;
         
           if(a=='Re Scheduling')
           {
               document.getElementById('section1').style.display='none';
           }else
           {
                document.getElementById('section1').style.display='block';
           }
        }
    </script>
    <apex:form id="form1">
        <label><b>Status</b></label>
        <apex:inputField id="status1" onchange="hidesection();"  value="{!lead.status}"/><br/>
        <div id="section1">
            Section 1 will hide when status is pending
        </div><br/>
        <div id="section2">
            Section 2 will not change
        </div>
    </apex:form>
 
</apex:page>

The above will hide the div section1 when ever status is changed to "Re Scheduling"

Output(initial screen on page load)



Output(after selecting picklist value as "Re Scheduling")


No comments:

Post a Comment

Tools for Lightning Web Component Development

 Below are the tools required for Web Component Development 1. Chrome Browser (Prefered) You can download it from Google 2. Visual Studio Co...