Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › How to make a Search Bar using Javascript in Salesforce?

    Tagged: Account, Javascript in Salesforce, Salesforce Apex, Salesforce Records, Salesforce SOQL, Search Box

    • Salesforce® Discussions

      How to make a Search Bar using Javascript in Salesforce?

      Posted by Manpreet on March 22, 2017 at 7:39 AM

      How to make a searchbar for Account records using Javascript?

      Vikas Kumar replied 8 years, 8 months ago 2 Members · 1 Reply
      • Account
      • Javascript in Salesforce
      • Salesforce Apex
      • Salesforce Records
      • Salesforce SOQL
      • Search Box
    • 1 Reply
    • Vikas Kumar

      Member
      March 23, 2017 at 3:00 PM

      Hi Manpreet,

      you can try something like this

      Page

      <apex:page controller="SearchJavascriptController">
      <html>
      <head>
      <style>

      * {
      box-sizing: border-box;
      }

      #myInput {
      background-image: url('/css/searchicon.png');
      background-position: 10px 10px;
      background-repeat: no-repeat;
      width: 100%;
      font-size: 16px;
      padding: 12px 20px 12px 40px;
      border: 1px solid #ddd;
      margin-bottom: 12px;
      }

      #myTable {
      border-collapse: collapse;
      width: 100%;
      border: 1px solid #ddd;
      font-size: 18px;
      }

      #myTable th, #myTable td {
      text-align: left;
      padding: 12px;
      }

      #myTable tr {
      border-bottom: 1px solid #ddd;
      }

      #myTable tr.header, #myTable tr:hover {
      background-color: #f1f1f1;
      }
      </style>
      </head>
      <body>

      <apex:form id="theForm">
      <apex:pageBlock >
      <h2>My Account</h2>
      <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
      </input>
      </apex:pageBlock>
      <table id="myTable">
      <tr>
      <th><h1> ACCOUNT NAME</h1></th>
      <th><h1> ACCOUNT ID</h1></th>
      <th><h1>ANNUAL REVENUE</h1></th>
      </tr>
      <apex:repeat value="{!accountList}" var="acc" id="theRepeat">
      <tr>
      <td>{!acc.name}</td>
      <td>{!acc.id}</td>
      <td>{!acc.AnnualRevenue}</td>
      </tr>
      </apex:repeat>
      </table>
      <script>
      function myFunction() {
      var input, filter, table, tr, td, i;
      input = document.getElementById("myInput");
      console.log(input);
      filter = input.value.toUpperCase();

      table = document.getElementById("myTable");
      tr = table.getElementsByTagName("tr");
      for (i = 0; i < tr.length; i++) {
      td = tr[i].getElementsByTagName("td")[0];
      if (td) {
      if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {

      tr[i].style.display = "";
      } else {
      tr[i].style.display = "none";
      }
      }
      }
      }
      </script>
      </apex:form>
      </body>
      </html>

      </apex:page>

      Controller

      public with sharing class SearchJavascriptController {

      public list<Account>accountlist { get; set; }
      public SearchJavascriptController()
      {
      accountList = new list<Account>();
      accountList =[Select Name,Id,AnnualRevenue From Account];
      }

      }

      thanks

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    Salesforce vs Hubspot: Which CRM is the Best Fit for Your Business Needs?

    Blog in Salesforce

    As companies grow and expand, managing customer relationships becomes a complex and challenging task. This is where customer relationship management (CRM) software comes into play.…

    Attract, Benefits, Best Suited, budget, Business
    Kizzy Consulting Jul 3, 2023
    1,449  Views

    Omni-Channel Overview in 2024

    Blog in Others

    Omni-Channel is a Customer Service and console-based Salesforce feature that helps automatically route of different types of work items (such as Leads and Cases) to…

    Capacity, Configuration, Customer Communication, Customer Service, Flow
    Vimera | Andersen Apr 5, 2024
    709  Views

    Salesforce Einstein Voice – Stop typing and start Selling!

    Blog in Salesforce Einstein

    Imagine each of your Sales reps had a personal assistant who could handle monotonous and boring tasks while your Sales reps stay focused on their…

    CRM, CRM Technology, Data Protection in Salesforce, Developer Org, Einstein Bots
    DemandBlue Nov 26, 2018
    5,809  Views

    Popular Salesforce Videos

    Email to case in Salesforce | Learn Salesforce

    Email to case in Salesforce | Learn Salesforce

    Video in Salesforce Training

    In this video, Shrey explained complete Record Level Security in Salesforce which includes: 1. What is Email-to-case in Salesforce? 2. Where can Email-to-case be used?…

    Salesforce Training, Salesforce Implementation, salesforce, Learn Salesforce, Salesforce Video
    Jogender Apr 7, 2021
    2,200  Views
    Salesforce — How To Improve Customer Service for Small Businesses

    Salesforce — How To Improve Customer Service for Small Businesses

    Video in Salesforce Stories

    How can a small business improve its customer service? More than ever before, supporting customers is key to a small business's survival — so give…

    salesforce, Salesforce Video, Customers, customer service, Salesforce Learning
    Nauman Sep 15, 2020
    2,289  Views
    Customer Lifecycle Analytics | Salesforce

    Customer Lifecycle Analytics | Salesforce

    Video in Others, Salesforce Stories

    Customer Lifecycle Analytics, built on Tableau CRM, helps you glean even more value from your Salesforce Surveys and Salesforce Feedback Management responses with embedded analytics…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Salesforce Surveys
    Neha Yadav Jan 29, 2021
    2,093  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2025 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.