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
RossCo@DiscoveryRossCo@Discovery 

Hardcode apex:selectionoptions?

Hi Everyone

 

Is it possible to hard-code the options for apex:selectoptions (ie: not call a method in the controller) - I only have a few non-variable options.

 

Many thanks for any assistance

Ross

 

 <apex:selectOptions value="{!items}"/>
bob_buzzardbob_buzzard

Yes - simply put the appropriate number of <apex:selectOption/> elements inside the selectlist.  From the developer's guide:

 

<apex:selectList id="chooseColor" value="{!string}" size="1">
  <apex:selectOption itemValue="red" itemLabel="Red"/>
  <apex:selectOption itemValue="white" itemLabel="White"/>
  <apex:selectOption itemValue="blue" itemLabel="Blue"/>
</apex:selectList>