Best Answer · By JanBask Salesforce Expert
Ranjana Admin JanBask Expert
Answered on Jan 29, 2020
 By using Action Support function we can achieve this scenario
public class ActionSupportController
{
  public list lstoption {get; set;}
  public list lstaccount {get; set;}
  Public List lstContacts {get; set;}
  Public string selectedAccount {get;set;}
    public ActionSupportController()
      {
        lstoption=new list();
        lstaccount= [select id,name from account order by name];
        lstoption.add(new selectoption('','--None--'));
        for(account acc: lstaccount)
          {
            lstoption.add(new selectoption(acc.id,acc.Name));
          }
      }
  Public PageReference LoadContacts()
  {
    lstContacts = [select id, firstname, lastname,phone,LeadSource,Department,Status__c,Email from contact where accountid =: selectedAccount];
    return null;
  }
}
 Â
   Â
     Â
       Â
       Â
        Â
   Â
 Â
 Â
   Â
     Â
     Â
      Â
      Â
      Â
      Â
   Â
 Â