Widget: Search

From Mr Love Queen's Choice
Jump to: navigation, search
   <input type="text" style="min-width:200px;" id="search-text" placeholder="Search">

<script type="text/javascript">

   document.getElementById('search-text').onkeyup = function(event) {
       search();
   };
   function search() {
       var searchText = document.getElementById("search-text").value.toUpperCase();
       var list = document.getElementsByClassName("search-entry");
       
       for (var i = 0; i < list.length; i++) {
           var item = list[i];
           if (item.attributes['data-search-text'].value.toUpperCase().indexOf(searchText) > -1) {
               item.style.display = ;
           } else {
               item.style.display = 'none';
           }
       }
   }

</script>