How to make the script search not by text but by select?

Code:

(function($){ $.fn.tableSearch = function(options){ if(!$(this).is('table')){ return; } var tableObj = $(this), searchText = (options.searchText)?options.searchText:'Search: ', searchPlaceHolder = (options.searchPlaceHolder)?options.searchPlaceHolder:'', divObj = $('<div style="float:right;">'+searchText+'</div><br /><br />'), inputObj = $('<input type="text" placeholder="'+searchPlaceHolder+'" />'), caseSensitive = (options.caseSensitive===true)?true:false, searchFieldVal = '', pattern = ''; inputObj.off('keyup').on('keyup', function(){ searchFieldVal = $(this).val(); pattern = (caseSensitive)?RegExp(searchFieldVal):RegExp(searchFieldVal, 'i'); tableObj.find('tbody tr').hide().each(function(){ var currentRow = $(this); currentRow.find('td').each(function(){ if(pattern.test($(this).html())){ currentRow.show(); return false; } }); }); }); tableObj.before(divObj.append(inputObj)); return tableObj; } }(jQuery)); $(document).ready(function(){$('table.search-table').tableSearch({searchText:'Поиск',search:'Напишите название'});}); 
  • And where is the select? - Mrak

1 answer 1

Perhaps Typeahead will help you in your case. This is a ready-made solution to search from existing values ​​with a drop-down hint.

  • Please tell me how to connect it here igroteka.club/Tablica2/sample-table.html - Kasper Ghost
  • twitter.imtqy.com/typeahead.js/examples is the answer to the question how to connect. - Alexey Niemtsov
  • For example, I insert these lines from the example <Default Suggestions> And nothing works. I just don’t understand this honestly so sorry for stupid questions - Kasper Ghost
  • Here is the page where I eat it shove igroteka.club/Tablica2/sample-table.html - Kasper Ghost
  • The easiest option: The values ​​of the desired column to push into the array JS, which will then be used to search. In the basic example, this is implemented. And you will be happy. - Alexey Niemtsov