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
MikeGillMikeGill 

Show selectList as dropdown - am I missing something

I am trying to output a custom picklist in a visualforce page

 

This works fine - but I'm lost to how to make it display as a drop-down

 

<apex:page controller="sampleCon">
    <apex:form >
        <apex:selectList value="{!countries}" multiselect="true">
            <apex:selectOptions value="{!items}"/>
        </apex:selectList><p/>

        <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    </apex:form>

    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
</apex:page>

 

Please can someone point me in the right direction - thanks

Best Answer chosen by Admin (Salesforce Developers) 
MikeGillMikeGill

Here is the trick

 

     <apex:selectList value="{!countries}" multiselect="false" size="1">

All Answers

JoyDJoyD

You can't do multi-select as a drop-down, I believe if you change that setting I think it'll fix it?

 

MikeGillMikeGill

Actually removed that - it just all values in select list. Know what I mean?

MikeGillMikeGill

Here is the trick

 

     <apex:selectList value="{!countries}" multiselect="false" size="1">

This was selected as the best answer
A WannabeA Wannabe

Thanks Mike you saved my day!