I want to create a VF page which in which i can search all accounts dyanamically without using button. It should work on pressing a key from keyboard. How can i achieve this. Help me out
public class SearchOnKeyupC {
public list<Account> accounts { get; set; }
public String name { get; set; }
public SearchOnKeyupC(){
accounts = new list<Account>();
//accounts = [Select Name,Rating,Phone From Account];
}
public pageReference searchAccounts(){
string query = '';
if(name != ''){
query = 'Select Name,Rating,Phone From Account Where Name like \''+name+'%\'';
accounts = database.query(query);
}
else{
//query = 'Select Name,Rating,Phone From Account';
//accounts = database.query(query);
accounts = new list<Account>();
}
return null;
}
}
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
public class SearchOnKeyupC {
public list<Account> accounts { get; set; }
public String name { get; set; }
public SearchOnKeyupC(){
accounts = new list<Account>();
//accounts = [Select Name,Rating,Phone From Account];
}
public pageReference searchAccounts(){
string query = '';
if(name != ''){
query = 'Select Name,Rating,Phone From Account Where Name like \''+name+'%\'';
accounts = database.query(query);
}
else{
//query = 'Select Name,Rating,Phone From Account';
//accounts = database.query(query);
accounts = new list<Account>();
}
return null;
}
}
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas