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
Nirmal9114Nirmal9114 

how to show description of picklist select in a VF Page. Please Help

My Requirement is to Show Description beside the DOCKET picklist value. the description should change as the picklist value changes.The page should dynamically render the description from the selected Docket
Can anyone give me the idea how to do it.

User-added image

BALAJI CHBALAJI CH
Hi Nirmal,

Please find below example for actionsupport with selectlist and get selected value. 

VF Page
<apex:page controller="ActionSupportTest" showHeader="true">
    <apex:form id="form">
        
        <apex:pageMessages/>
        <apex:selectList value="{!discountScheduleID}" size="1" >
            <apex:actionSupport event="onchange" action="{!calcPricing}" rerender="form"/>
            <apex:selectOptions value="{!schedules}" />
        </apex:selectList>  
        <h1>{!description}</h1><br/>
    </apex:form>
</apex:page>

Controller:
public class ActionSupportTest {
    public SelectOption[] getSchedules() {
        return new SelectOption[] { new SelectOption('Value1', 'Option1'), 
            new SelectOption('Value2', 'Option2'), new SelectOption('Value3', 'Option3') };
    }

    public String discountScheduleID { get; set; }
     public String description{ get; set; }
    
    public PageReference calcPricing(){
        if(discountScheduleID == 'Value1')
        {
            description='First';
        }
        if(discountScheduleID == 'Value2')
        {
            description='Second';
        }
        if(discountScheduleID == 'Value3')
        {
            description='Third';
        }
        return null;
    }
}

Let us know if that helps you.

Best Regards,
BALAJI
Nirmal9114Nirmal9114
My VF page Code is this for that section : IT is not working

         <apex:pageBlockSection columns="1" >   
            <apex:pageBlockSectionItem>
                <apex:outputLabel Value="Dockets" /> 
                  <apex:outputPanel layout="Block" id="GuPanel" styleClass="requiredInput"> <!--Priyanka -->
                        <apex:outputPanel id="thePanel" styleClass="requiredBlock" />   <!--Priyanka -->
                                               
                            <apex:selectList value="{!campId}" multiselect="false" id="account" size="1" styleClass="picklistClass1" >
                        <apex:selectOptions value="{!CampaignItems}" />                        
                       <apex:pageMessages/>                
                    <apex:actionSupport event="onchange" action="{!getCampaigns}" rerender="form"/>        
                    </apex:selectList>       
                    <apex:actionStatus id="loadGU" startText="Loading..."/>
               </apex:outputPanel>    
            </apex:pageBlockSectionItem>