Visualforce – Get All Accounts Related to Name Written in Input field

To Achieve this Functionality, one needs to use Jquery.

In order to use Jquery , Upload Jquery Script as a Static resource in your Salesforce Organization and Use this Script in Visualforce Page.

In order to take understanding as how it works please refer to the following URL.

Here is the Controller and Visualforce Page.

<apex:page sidebar="false" controller="FindAccountRelated_To_Search_Ext" >
<apex:includeScript value="{!$Resource.JqueryScript}"/>

<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
Account Name : <input type="text" name="fname" id="SearchVal" />


<apex:pageBlock title="All Accounts" id="acc">

<apex:pageblockTable value="{!AllAccounts}" var="accs">

<apex:column value="{!accs.Id}" headervalue="Account Id"/>
<apex:column value="{!accs.Name}" headerValue="Account Name"/>


<apex:actionFunction action="{!RelatedAccounts}" name="searchrecords" reRender="acc" >
<apex:param name="serchval" value="serchval" assignTo="{!AccName}"/>

<script type = "text/javascript"> 
 var serchval = $(this).val();


public with sharing class FindAccountRelated_To_Search_Ext {

public String AccName {get;set;}
public List<Account> AccountList {get;set;}

public PageReference RelatedAccounts(){

return null;

public List<Account> getAllAccounts(){

AccountList = [Select ID,Name From Account Where Name LIKE : ('%'+AccName+'%') ];
return AccountList;


Some points which you should know for this Visualforce Page.

1 – Use Input Field for Name of Account.

2 – Use Pageblock Table or DataTable For Display Records.

3 – Use Keypress  Jquery Event to Get the Input.

4 – Use Action function to Send the Input Value to Controller.

5 – Use SOQL Query In controller to Get All Related Records as Written in Input Field.


Please Follow if you like my Blog and share your valuable inputs.





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

Up ↑

SFDC Panther

A hub for Salesforce Tutorial - Salesforce Classic/Lightning

SFDC Knowledge Bank

Solutions With Best Possible Options


Adventures in Salesforce

Analysis Paralysis

Ramblings from a Salesforce Business Analyst

Ajomon Joseph


Adam To Architect

Journey from Adam to Architect

Andy in the Cloud

From BBC Basic to and beyond...

Sara Has No Limits

Good Programmers Evaluate, Simplify, Automate and Document

Douglas C. Ayers

My journey with Salesforce and Technology

Shruti Sridharan

Salesforce Enthusiast | Tech Addict | IoT Specialist | Travel Maniac | Photography | Music Lover | Foodie

Andrew Boettcher - Salesforce Technologist

Random musings from a dad with a passion for technology...

Nitin Gupta

Just One Idea

Salesforce coding lessons for the 99%

Finally, Apex tutorials for point-and-click admins! Written by a self-taught Google engineer.

Automation Champion

Automating Salesforce One Click at a Time

Pritam Shekhawat

All About

Sagar Sindhi

Salesforce Developer | Passionate for Salesforce | Salesforce Lover | Trailhead Addicted | Blogger

%d bloggers like this: