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, 10 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

    Process Builder in Salesforce

    Learning All About Process Builder in Salesforce

    Blog in Salesforce

    Cycle Builder Salesforce is in a general sense a robotized gadget that licenses you to control the task for exercises or survey the models for…

    builder, Chatter, Cycle Builder, Cycle Builder Salesforce, Cycle Requests
    Marziya Nov 24, 2020
    3,410  Views

    Value of Salesforce in Small and Medium Business

    Blog in Others

    Speed is the quintessence of the business world. That is valid for almost every part of our business, yet it's particularly valid for innovation and…

    Business Operations, Business Success, Community Cloud, Dreamforce, Marketing Cloud
    Christi Mar 6, 2018
    3,741  Views
    What are List Views in Salesforce?

    What are List Views in Salesforce?

    Blog in Others

    Hello everyone, In this blog, we will discuss about “List Views in Salesforce". Let's begin with what list views are.  What are List Views? In…

    Collection, Collections in Apex, Collections in Salesforce, Customise and Filter Related Lists, Duplicate Elements
    Nikhil Kumar Jan 16, 2023
    1,558  Views

    Popular Salesforce Videos

    Salesforce Lightning Training - Creating Hello World Lightning Component

    Salesforce Lightning Training - Creating Hello World Lightning Component

    Video in Lightning, Salesforce Training

    Data Loader is a utility to perform bulk database operation. Recently Salesforce has changed the way data loaders need to be install. I explain end…

    Salesforce Training, Salesforce Lightning, salesforce, Salesforce Lightning Training, Salesforce Video
    Sam J Apr 28, 2020
    2,321  Views
    How to implement Salesforce shield in 20 min?

    How to implement Salesforce shield in 20 min?

    Video in Salesforce Security

    Many organizations have “bought” Salesforce Shield but haven’t implemented it yet, due to some complexities that come along with security-related products. Pete and Brian will…

    Salesforce Tutorial, Salesforce Security, Salesforce Tutorial for Beginners, Salesforce Implementation, salesforce
    Abhay Aug 20, 2018
    3,674  Views
    Watch and Learn with Salesforce Developers

    Watch and Learn with Salesforce Developers

    Video in Salesforce Training

    Salesforce Developers are creators that live on the cutting edge of technology and innovate with the newest tools. The Salesforce Developer YouTube Channel is here…

    Salesforce Training, Salesforce Tutorial, Salesforce Development, Salesforce Developers, Salesforce Video
    Nauman Sep 7, 2021
    1,584  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

    © 2026 - 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.