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
SFDC@ChennaiSFDC@Chennai 

How to get the selected pick list values in onload method of controller?

Hi
In the pick list i have six values like 6,12,18,24,30 &36.
In VFP, if i choosed 18 it shold get it in controller's/onload method of apex class.

Can any one share the idea to get this?
Arunkumar RArunkumar R
Are you using inputField or you are generating SelectList and using the value in your visualforce page..?

Can you post code here it will be helpful to provide answer..


Anoop yadavAnoop yadav
Hi,

Check the below Link with Demo.
By clicking the save Button,  you will get the selected values.
http://www.sfdcpoint.com/salesforce/custom-picklist-in-visualforce-salesforce/
SFDC@ChennaiSFDC@Chennai
@Arunkumar R

Yes, I Created Pick list filed and loaded those values,  then i used render/re rendered  for generating it

Thanks,
Arunkumar RArunkumar R
Hi,

Please find the below sample code,

Apex:
public with sharing class PicklistController 
{
    public opportunity opp;
    public PicklistController(ApexPages.StandardController controller) 
    {
         opp = (Opportunity)controller.getRecord();    
    }
    
    public void selectedPicklistValue()
    {
         System.debug('---Stage Value'+opp.StageName); 

    }
    
}

Visualforce page:

<apex:page standardController="Opportunity" extensions="PicklistController">
 <apex:form>
 <apex:inputField value ="{!Opportunity.StageName}">
 <apex:actionSupport event="onchange" action="{!selectedPicklistValue}"/>
 </apex:inputField>
 </apex:form>
</apex:page>