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
narendharnarendhar 

Passing pick list values from visualforce page to controller

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Narendhar,

To custom visual force picklist value passing to a controller.Please check the below code.

VFPage:
<apex:page controller="Opp">
  <apex:form>
    <apex:outputLabel value="Qualification  :  " for="stagename"/>
    <apex:selectList multiselect="false" value="{!filter}" label="Qualification" size="1" id="stagename">
      <apex:selectOption itemValue="" itemLabel="--Select--"/>
      <apex:selectOption itemValue="Closed Won" itemLabel="Closed Won"/>
      <apex:selectOption itemValue="Closed Lost" itemLabel="Closed Lost"/>
      <apex:actionSupport event="onchange" reRender="pgbtable" action="{!getresult}" status="status"/>
    </apex:selectList>
    <apex:actionStatus id="status">
      <apex:facet name="start">
        <div>Loading Please wait........</div>
      </apex:facet>
    </apex:actionStatus>
    <apex:pageBlock >
      <apex:pageBlockTable value="{!OppList2}" var="op2" title="Opportunities" id="pgbtable">
        <apex:column value="{!op2.name}"/>
        <apex:column value="{!op2.Accountid}"/>
        <apex:column value="{!op2.CloseDate}"/>
        <apex:column value="{!op2.Ownerid}"/>
        <apex:column value="{!op2.Probability}"/>
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

Controller:
public class Opp {
    public String filter{get; set;}
    public List < Opportunity > OppList2 {
        get;
        set;
    }

    string searchquery = 'select name,accountid,ownerid,closedate,Probability from Opportunity ';

    public Opp() {
        OppList2 = Database.query(searchquery);
    }
    public void getresult() {
        searchquery = 'select name,accountid,ownerid,closedate,Probability from Opportunity where StageName = :filter ';
        OppList2 = Database.query(searchquery);
    }
}

Please check the below links for reference. I hope it will be helpful.

BestRegards
​RahulKumar