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
sushmaiyer2@gmail.comsushmaiyer2@gmail.com 

How to dynamically get valued in VF picklist which are added through Salesforce CRM?

 

Hi All,

I would like to know how to dynamically get values for my picklist in VF page for which i am adding values through the Salesforce CRM with out statically mentioning in inputfield.

Also,is there a way to create picklist using Java script?

 

Maros SitkoMaros Sitko

dynamickly filled picklist

 

public list<String> getPiclistOptions() {
        list<String> options = new list<String>();
        options.add(new SelectOption('','All'));
        // your logic

        return options;
}

 

 

in visualforce

<apex:selectList value="{!selected}" size="1" >
   <apex:selectOptions value="{!PicklistOptions}" />
</apex:selectList>

 if you make some rerender over picklist, it will always have new values based on your logic in method getPicklistOptions

 

if you want use javascript for build picklist, you can. You will create picklist via visualforce and controller without options, and you will add options with javascript - I recommand jquery for this. For example http://stackoverflow.com/questions/740195/adding-options-to-a-select-using-jquery-javascript