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:'Напишите название'});});