-
How can we fetch data without using Controller functions on salesforce VisualForce page?
Hi All,
I am in a scenario where i need to search data using keypress action from a list of accounts and i need to use javascript function in this not controller function.Is there any way to do this.i have written the following code:
<apex:page controller="SearchAccountJS">
<script>
function search(){
if( name != ''){
var str=sforce.connection.query('SELECT id,Name,AnnualRevenue FROM Account WHERE Name like \''+name+'%\'');
records= str.getArray("records");
alert('1'+records);}
else{
var str = sforce.connection.query('SELECT id,Name,AnnualRevenue FROM Account');
records=str.getArray("records");
alert('2'+records);}
</script>
<apex:form >
<apex:actionFunction name="ApexMethod" action="search()" rerender="accountTable"/>
<apex:pageBlock >
<apex:outputText value="Account Name"/>
<apex:inputText value="{!name}" onkeyup="ApexMethod" />
<apex:pageBlockSection id="accountTable" columns="3">
<apex:pageblocktable value="{!accounts}" var="acc">
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.id}"/>
<apex:column value="{!acc.AnnualRevenue}"/></apex:pageblocktable>
</apex:pageBlockSection></apex:pageBlock>
</apex:form>
</apex:page>Controller here is only used for printing list of accounts.
Log In to reply.
Popular Salesforce Blogs
![Health Cloud Console](https://images.forcetalks.com/wp-content/uploads/2022/11/23200200/Health-Cloud-Console.jpg)
Health Cloud Console Unit in Salesforce - Get Started
In this blog, we will discuss about Health Cloud, its specific terminology, and its architecture. Let’s move to Salesforce Health Cloud Core Capabilities which are:…
![](https://images.forcetalks.com/wp-content/uploads/2021/08/05080503/sa_1628150675Business%20challenges%20%202-1024x576.png)
Brave Your Business Challenges With Salesforce
As any business grows, it faces a plethora of challenges along the way. To keep up with the cut-throat market competition, it is extremely important…
![](https://images.forcetalks.com/wp-content/uploads/2020/10/06044840/sa_1601959669ThingsYouNeedtoConsiderwhileIntegratingWordPressandSalesforce1.jpg)
Things You Need to Consider While Integrating WordPress and Salesforce
WordPress and Salesforce are no less than a match made in heaven. When you go for a WordPress Salesforce Integration (WordPress website with Salesforce as…
Popular Salesforce Videos
Why Are Some of The World’s Biggest Brands Transitioning Towards Headless? | Salesforce
With the advancement of headless architecture, consumers can now enjoy an omnichannel shopping experience. But that's not all that headless commerce has to offer. Leading…
Custom Portfolio in Salesforce | Mini Project | Salesforce Tutorials
In this video, we will create a custom portfolio in Salesforce. We will create a custom community in Salesforce and customize it to create the…
Salesforce CPQ Subscription Pricing
Configure Price Quote (CPQ) is a powerful sales tool that enables companies to produce accurate and highly configured sales quotes for customers — especially in…