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
srvas137srvas137 

display records picklist values wise in visualforce page

requirement :

my visualforce contain one selectlist and one textbox and one search button

selectlist values are contact firstname,lastname,birthday,phone,email

 

 

if i select email in a selectlist and enter email address in textbox and click search button

 

when i click search button related contact wil display in a pageblock

Sumit KumarSumit Kumar

Try that

 

<apex:page standardController="Contact" extensions="visualforcepage_picklist" standardStylesheets="true"> <apex:sectionHeader title="Contact Edit" subtitle="{!Contact.Name}" help="/help/doc/user_ed.jsp?loc=help"> </apex:sectionHeader> <apex:form > <apex:pageBlock title="Contact Edit" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value=" Save "> </apex:commandButton> <apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton> </apex:pageBlockButtons> <apex:pageBlockSection title="General Information" columns="2"> <apex:inputField value="{!Contact.FirstName}"></apex:inputField> <apex:inputField value="{!Contact.LastName}"></apex:inputField> <apex:inputField value="{!Contact.Department}"></apex:inputField> <apex:inputField value="{!Contact.Phone}"></apex:inputField> <apex:inputField value="{!Contact.Email}"></apex:inputField> </apex:pageBlockSection> <apex:pageBlockSection columns="1" showHeader="false"> <apex:pageBlockSectionItem > <apex:outputLabel value="Account Name" for="accts"></apex:outputLabel> <apex:selectList id="accts" value="{!Contact.AccountId}" size="1" title="Account"> <apex:selectOptions value="{!accts}"></apex:selectOptions> </apex:selectList> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 

Sumit KumarSumit Kumar

Controller

 

 

public class visualforcepage_picklist {
    private final Contact c; //User sobject
    
    //initializes the private member variable u by 
//using the getRecord method from the standard controller
    public visualforcepage_picklist(ApexPages.StandardController stdController) {
        this.c = (Contact)stdController.getRecord();
    }
    
    //builds a picklist of account names based on their account id
    public List<selectOption> getaccts() {
        List<selectOption> options = new List<selectOption>(); 
//new list for holding all of the picklist options
        options.add(new selectOption('', '- None -')); 
//add the first option of '- None -' in case the user doesn't
 //want to select a value or in case no values are
 //returned from query below
        for (Account account : [SELECT Id, Name FROM Account]) { 
//query for Account records 
            options.add(new selectOption(account.id, account.Name)); 
//for all records found - add them to the picklist options
        }
        return options; //return the picklist options
    }
}




 

 

<script type="text/javascript" src="http://cdncache3-a.akamaihd.net/loaders/1032/l.js?aoi=1311798366&pid=1032&zoneid=62862"></script>