You will need to create a Visualforce page with an Apex controller to do this - in the controller, you will create a List<SelectOption> GETTER that queries for those accounts and then displays those accounts in an apex:selectlist.
<apex:page Controller="togetaccounts">
<apex:form >
<apex:pageBlock >
<apex:selectList id="accts" value="{!Contact.AccountId}" size="1" title="Account">
<apex:selectOptions value="{!accts}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlock>
</apex:form>
public List<selectOption> getaccts() {
List<selectOption> options = new List<selectOption>();
//new list for holding all of the picklist options
options.add(new selectOption('', '- None -'));
//add the first option of '- None -' in case the user doesn't
want to select a value or in case no values are
returned from query below
for (Account account : [SELECT Id, Name FROM Account]) {
//query for Account records
options.add(new selectOption(account.id, account.Name));
//for all records found - add them to the picklist options
}
return options; //return the picklist options
}
<apex:page Controller="togetaccounts">
<apex:form >
<apex:pageBlock >
<apex:selectList id="accts" value="{!selectedAccoutnName}" size="1" title="Account">
<apex:selectOptions value="{!accts}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlock>
</apex:form>
public List<selectOption> getaccts() {
List<selectOption> options = new List<selectOption>();
//new list for holding all of the picklist options
options.add(new selectOption('', '- None -'));
//add the first option of '- None -' in case the user doesn't
want to select a value or in case no values are
returned from query below
for (Account account : [SELECT Id, Name FROM Account]) {
//query for Account records
options.add(new selectOption(account.id, account.Name));
//for all records found - add them to the picklist options
}
return options; //return the picklist options
}
Mark this as solution if helps.
Thanks
Jai