You need to sign in to do that
Don't have an account?

data in the dropdown list
Hi all,
On my Visualforce page, I would like to display the account names in a dropdown list.
For each account record, I have a custom field called display. If that display box is ticked, I would like to display the name of the account in the list.
Is there a way to do that please?
Many thanks
Hello Tin;
Controller:
public class MyClass{
public List<SelectOption> getAccountList() {
Account[] accounts = [SELECT name FROM Account WHERE display = true];
List<SelectOption> options = new List<SelectOption>();
for (Account acc : accounts) {
options.add(new SelectOption('',acc.Name));
}
return options;
}
}
VF Page:
<apex:page controller="MyClass">
<apex:form>
<apex:selectlist size="1">
<apex:selectoptions value="{!accountList}"></apex:selectoptions>
</apex:selectlist>
</apex:form>
</apex:page>
Hi prageeth,
Many thanks for your reply. The code works beautifully if it is on it's own. If I were to put it in the existing class for existing page, it throws me an error message on the visualforce page saying accountList unknown.
But I now have an idea.
Much appreciated your reply.
Thanks
Hi,
how to get the Account name in the controller after selecting any one Account in visulforce???
Thanks in Advanve.
accountList replace with getaccountList in visual force page
How to use the same method to display CONTACT NAME in VF PAGE ?