-
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
![API Versions](https://images.forcetalks.com/wp-content/uploads/2021/04/22180110/API-Versions.jpg)
API Versions in Salesforce - All You Need to Know
As a feature of a controlled Metadata API delivery and source control procedure, it is essential to see how API forms impact functioning examples, particularly…
![4 Favorite Spring 18 Release Features](https://images.forcetalks.com/wp-content/uploads/2018/01/25082927/4-Favorite-Spring-18-Release-Features.png)
4 favorite Salesforce Spring ’18 Release features
There has been a lot of buzz in the cyberspace about the much awaited Salesforce Spring '18 Release. Even though the Salesforce Spring '18 Release…
Popular Salesforce Videos
How to Become Salesforce Developer in 2022 | Salesforce Career Path
Anyone can become a Salesforce developer. It takes to learn Salesforce-specific developer skill sets and does not account for time spent in formal education or…
Custom Login Page Using Mulesoft | Salesforce Tutorial
In this video, you will learn how to create a custom login page using Mulesoft. Watch and learn. If you have any doubts do let…
Kizzy Consulting Salesforce Services - Grow Your Business 2X With Salesforce CRM
Kizzy Consulting is a Salesforce Ridge Consulting Partner in the USA and has successfully implemented 100+ Salesforce projects for 100+ clients across sectors like Financial Services,…