I have a list and i want to display on visualforce page as a dropdown menu with some options greyed out. I am not sure how to make some options non- clickable.

I'd appreciate any useful links or suggestions.


1 Answer 1


So I am assuming that you have already used that list and created a list of type selectOptions as this will be used to display the values in the drop down. When creating the selectoptions list you can mention whether to disable a particular value in the dropdown.

The selectOption constructor can take 3 arguments (value, label, isDisabled). So you can set the isDisabled to true for whichever values you want to keep it as non-clickable

You can do something like this(I copied this from here):

public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('US','US'));
    //set the 3rd argument to true for the values which you want to be disabled.
    options.add(new SelectOption('CANADA','Canada',true));
    options.add(new SelectOption('MEXICO','Mexico'));

    return options;

<apex:selectCheckboxes value="{!countries}" title="Choose a country">
        <apex:selectOptions value="{!items}"/>

You must log in to answer this question.

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