I'm having problems getting a list inside of a tag to render as a dropdown picklist. I don't want the picklist to appear as a multi-select picklist, with all possible values displayed as a list, but instead as a standard HTML dropdown where you only see the first value and then click the list to see the rest. Any pointers as to what I'm doing wrong here?

nb this is a simplified version of the controller and page. Lots of extra code omitted that has nothing to do with the problem at hand.

rendered picklist

controller code:

public class ots{

 public Id gId = ApexPages.currentPage().getParameters().get('gId');
//system.debug('gId is: '+gId);

 Opportunity o = [SELECT id, Competitor_s__c from Opportunity where Id =:gId];
 public List<SelectOption> comps {get;set;} 
 public List<OpportunityLineItem> olist {get;set;}
 String[] tempstring {get;set;}

public List<SelectOption> getfixedVals(){
    List<SelectOption> stomps = new List<SelectOption>();
    stomps.add(new SelectOption('Test 1','Test 1'));
    stomps.add(new SelectOption('Test 2','Test 2'));
    stomps.add(new SelectOption('Test 3','Test 3'));

    return stomps;


page code:

<apex:page controller="ots">
  <apex:selectList id="dropdown"> 
  <apex:selectOptions value="{!fixedVals}" rendered="true">
  • 1
    Can you try adding size="1" attribute in <apex:selectList> .Like <apex:selectList id="dropdown" size="1"> Commented Mar 22, 2018 at 10:24

2 Answers 2


For apex:selectList, set the attribute multiselect as false and size as 1.

<apex:selectList id="dropdown" multiselect="false" size="1"> 
    <apex:selectOptions value="{!fixedVals}" rendered="true">
  • Thanks for that pointer Rahul, exactly what I was looking for !
    – akarnid
    Commented Mar 22, 2018 at 10:41

Check out the page of https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_selectList.htm. You can set the size as well as the multiselect attribute

  • Damn - too late :)
    – utm
    Commented Mar 22, 2018 at 10:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .