create a search bar in javascript

Solutions on MaxInterview for create a search bar in javascript by the best coders in the world

showing results for - "create a search bar in javascript"
Fergus
18 Nov 2018
1<!DOCTYPE html>
2<html>
3<head>
4<meta name="viewport" content="width=device-width, initial-scale=1">
5<style>
6* {
7  box-sizing: border-box;
8}
9
10#myInput {
11  background-image: url('/css/searchicon.png');
12  background-position: 10px 12px;
13  background-repeat: no-repeat;
14  width: 100%;
15  font-size: 16px;
16  padding: 12px 20px 12px 40px;
17  border: 1px solid #ddd;
18  margin-bottom: 12px;
19}
20
21#myUL {
22  list-style-type: none;
23  padding: 0;
24  margin: 0;
25}
26
27#myUL li a {
28  border: 1px solid #ddd;
29  margin-top: -1px; /* Prevent double borders */
30  background-color: #f6f6f6;
31  padding: 12px;
32  text-decoration: none;
33  font-size: 18px;
34  color: black;
35  display: block
36}
37
38#myUL li a:hover:not(.header) {
39  background-color: #eee;
40}
41</style>
42</head>
43<body>
44
45<h2>My Phonebook</h2>
46
47<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
48
49<ul id="myUL">
50  <li><a href="#">Adele</a></li>
51  <li><a href="#">Agnes</a></li>
52
53  <li><a href="#">Billy</a></li>
54  <li><a href="#">Bob</a></li>
55
56  <li><a href="#">Calvin</a></li>
57  <li><a href="#">Christina</a></li>
58  <li><a href="#">Cindy</a></li>
59</ul>
60
61<script>
62function myFunction() {
63    var input, filter, ul, li, a, i, txtValue;
64    input = document.getElementById("myInput");
65    filter = input.value.toUpperCase();
66    ul = document.getElementById("myUL");
67    li = ul.getElementsByTagName("li");
68    for (i = 0; i < li.length; i++) {
69        a = li[i].getElementsByTagName("a")[0];
70        txtValue = a.textContent || a.innerText;
71        if (txtValue.toUpperCase().indexOf(filter) > -1) {
72            li[i].style.display = "";
73        } else {
74            li[i].style.display = "none";
75        }
76    }
77}
78</script>
79
80</body>
81</html>
82
queries leading to this page
create search javascriptjs input filtercreate a search box in html javascriptjs make a search boxinput filter functionhow do i connect a button to a search field jshow to create a search bar in javascriptsearch box using javascriptsearch bar with html and jscreating working search box with jshow to make a search bar node jsscript for search box in javascripthow to add search bar in javascripthow to do search bar using javascriptinput filtersearch bar logic javascripthow to add search bar in jshow to create search box in html using javascripthow to create searchbar in javascripthow to create a search bar with javascriptsearch bar working code javascripthow to create search function in javascriptsearch bar working with html and javascriptis it easy to make search bar in javascriptsearch bar how to make it work in jscreate search page javascripthow to make a javascript searchcreate search box javascripthow to make search box functional in javascripthow to make a search bar with javascripthow to make a search bar search javascriptcreate a search function javascripthow to make a search with javascriptsearch bar with javascript search bar jaavscriptarray filter in input value javascriptjs make search barsearch bar html jsworking search bar html javascripthow to make a js search bar for your websitesearchbar maken jsfilter input arrayhow to connect search bar javascriptadd a search bar with javascriptcreate a search bar in javascripthow to create search using javascriptcreate search bar in javascriptsearch bar using form in javascriptfilter input array jscreate search function javascripteasy js search barhow to make a search bar in javascriptsearch bar using javascriptimplement search bar in javascriptworking javascript search barhow to make a search bar that finds relevant searchs jssearch box in javascriptbuild search bar in javascripthow to create search bar in jsworking search bar javascriptsearchbar javascripthow to make a search bar for your website jssearch bar using jssearch bar function in javascriptcreating a search function in javascripthow to use the search bar function in javascriptfilter input w3schoolshow to do searchbar jshow to do a quick search bar in javascriptsearch bar js codew3schools javascript search barjavascript search barsinput with filtersearch bar javascript tutorialhow to make a working search bar in javascriptsearch field jscreate a search in javascriptjavascript search barcreate a search function in javascripthtml javascript search barcreate a javascript search barsearch box with javascripthow to do a search bar in jssearch bar in jshow to make a search bar functional with javascriptbuilding a search box with javascripthtml javascript search bar with results working search bar using javascriptcreate search box element javascriptfilter inputmake a search bar in javascriptsearch bar maken jsjavascript how to work with search barcustom search implementation in javascripthow to make a search button in domsearch bar java scriptdevelop javascript search barhow to use a search bar in javascripthtml filter file type inputsearch bar html javascripthow to make search using javascripthow to search bar work jshow to make a search bar in hjshow to create search box using domcreate a search menu jshtml javascript add search barmake a search in jshow to make a search bar nodejssearch bar using html and javascriptsearch box functionality in javascripthow to make search in javascriptsearch bar implementation in javascriptcreate search in javascriptcreate search box in javascriptjavascript search bar searching boxshow to create a search bar javascriptjs build a search barcustom search in javascripthow to create a search bar in javascript and display resultcreating a search bar with search button in javascriptcreate search bar in javascript show the datajavascript simple search boxhow to add search bar javascriptfilter inputshow to make a search bar jsjs implement search barmake search bar with javascripthow to make a search page with javascripthow to make a search functionality in javascriptmaking your own search bar for your website javascriptscript for search box in javascript codmake search bar javascripthow do you make a search bar function well in javascriptsearch bar in javascriptsimple search bar jshtml input filtercreate a search bar in html css jscreate a search box in javascripthow to make a search bar function in javascriptcreate search bar javascriptexecute javascript from search barhow to set up a search bar with jssearch bar javascript type searchhow to create a searchbox jscreating a search bar in javascriptcreate search with jsjavascript filter list with inputbest way to make a search javascripthow to create search in javascripthow to create js fuction which write in search boxinput value filter htmlchange search bar jssearch bar javascripthow to create a search bar in jshow to make a search box in jshow to create search bar in javascriptcreate a search bar in javascript