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

    Sample Web Service With Workbench

    Sample Web Service With Workbench

    Blog in Others

    Being a fresh learner of Salesforce this blog is helpful to guide you about writing a web service using Rest and calling the web service through…

    Get Method, HTTP Methods, JSON, POST Method, Record Id
    Archit Aug 21, 2018
    6,890  Views

    Managing Billing Processes in Salesforce: Subscription Management and CPQ (Configure-Price-Quote)

    Blog in Salesforce Tools

    In today's business landscape, retaining customers is the top priority for those who want to ensure scalability and predictable business growth. To achieve this, customers…

    Automated Billing, Bill processes, billing, Comprehensive features, Configure
    Twistellar Jul 11, 2023
    1,314  Views
    salesforce Testing

    Best Practices in Testing | Salesforce Developer Guide

    Blog in Salesforce

    To be successful in the IT sector, you must be familiar with all of the finest testing procedures. It is critical to have testing best…

    App Components, Automated Test Projects, Automated Testers, Best Practices, Best Practices in Testing
    Cymetrix May 27, 2021
    2,713  Views

    Popular Salesforce Videos

    Run UI Tests with UTAM | Salesforce Developer Tutorial

    Run UI Tests with UTAM | Salesforce Developer Tutorial

    Video in Salesforce Training, Salesforce Development

    Testing apps is critical to ensure quality and there are different types of tests such as unit tests, integrations tests or end-to-end tests just to…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, salesforce app
    Abhishek Jun 29, 2022
    3,438  Views
    An Introduction to Salesforce org Nonprofit Cloud

    An Introduction to Salesforce org Nonprofit Cloud

    Video in Salesforce For Nonprofits

    Did you know that over 30,000 nonprofit organizations use Salesforce? Salesforce.org’s premier product, NPSP, helps nonprofits drive greater impact by connecting everything they do. Learn…

    Salesforce Developer, Salesforce Lightning Experience, Salesforce Implementation, Marketing Automation, Salesforce CRM
    Pooja Nov 21, 2018
    2,591  Views
    Configuration Attribute In Salesforce CPQ | Salesforce Development Tutorial | Learn Salesforce Series by Algoworks

    Configuration Attribute In Salesforce CPQ | Salesforce Development Tutorial | Learn Salesforce Series by Algoworks

    Video in Salesforce Training

    Configuration attributes can be used in setting up the value of multiple shared product option fields simultaneously in Salesforce CPQ. In this Salesforce tutorial, you…

    Salesforce Training, Salesforce Tutorial, Salesforce CPQ, Salesforce Development Tutorial, Salesforce Video
    Algoworks Nov 30, 2020
    7,841  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.