diff --git a/dev/jquery.jtable.forms.js b/dev/jquery.jtable.forms.js index 0ef0c964..0d901767 100644 --- a/dev/jquery.jtable.forms.js +++ b/dev/jquery.jtable.forms.js @@ -1,6 +1,41 @@ -/************************************************************************ +/************************************************************************ * FORMS extension for jTable (base for edit/create forms) * *************************************************************************/ + +/////////////////////////////////////////////////////////////// + + +jQuery.fn.filterByText = function(textbox) { + return this.each(function() { + var select = this; + var options = []; + $(select).find('option').each(function() { + options.push({value: $(this).val(), text: $(this).text()}); + }); + $(select).data('options', options); + + $(textbox).bind('change keyup', function() { + var options = $(select).empty().data('options'); + var search = $.trim($(this).val()); + var regex = new RegExp(search,"gi"); + + $.each(options, function(i) { + var option = options[i]; + if(option.text.match(regex) !== null) { + $(select).append( + $('