<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>JavaScript filter/search in table</title>
    <link>http://blog.echarp.org/filterTable/index.rss</link>
    <description>JavaScript filter/search in table</description>
    <item>
      <title>Re: JavaScript filter/search in table</title>
      <pubDate>2012-01-11 03:03:09+0100</pubDate>
      <link>http://blog.echarp.org/Re_JavaScript_filtersearch_in_table_24</link>
      <comments>http://blog.echarp.org/Re_JavaScript_filtersearch_in_table_24</comments>
      <dc:creator>JOSE</dc:creator>
      <description>&lt;p&gt;0&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: JavaScript filter/search in table</title>
      <pubDate>2012-01-11 02:51:50+0100</pubDate>
      <link>http://blog.echarp.org/Re_JavaScript_filtersearch_in_table_23</link>
      <comments>http://blog.echarp.org/Re_JavaScript_filtersearch_in_table_23</comments>
      <dc:creator>JOSE</dc:creator>
      <description>&lt;p&gt;-1&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: JavaScript filter search in table</title>
      <pubDate>2011-03-14 15:42:49+0100</pubDate>
      <link>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_5</link>
      <comments>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_5</comments>
      <dc:creator>echarp</dc:creator>
      <description>&lt;p&gt;&lt;p&gt;I&amp;#8217;m not using it currently, but your changes are appreciated, and could be useful to others.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: JavaScript filter search in table</title>
      <pubDate>2011-03-14 15:01:48+0100</pubDate>
      <link>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_4</link>
      <comments>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_4</comments>
      <dc:creator>Austin</dc:creator>
      <description>&lt;p&gt;&lt;p&gt;I have no idea how old this is or if it is even still worked on, but i had to make some small modifications to get it working in Chrome/Firefox, so i will just add them here incase anyone else needs them.&lt;/p&gt;
&lt;p&gt;JavaScript Change:&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;CHANGE&lt;/span&gt;&lt;br/&gt;
function filterTable(term, table) {
	dehighlight(table);&lt;/p&gt;
&lt;p&gt;TO&lt;br/&gt;
function filterTable(term, table) {
	var term = document.getElementById(term);
	var table = document.getElementById(table);
	dehighlight(table);&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;HTML&lt;/span&gt; Change&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;CHANGE&lt;/span&gt;&lt;br/&gt;
filterTable(this.value, &amp;#8216;filterTable&amp;#8217;);&lt;/p&gt;
&lt;p&gt;TO&lt;br/&gt;
filterTable(&amp;#8216;searchClient&amp;#8217;, &amp;#8216;filterTable&amp;#8217;);&lt;/p&gt;
&lt;p&gt;In the function, &amp;#8220;searchCLient&amp;#8221; is the ID only of the textbox, &amp;#8220;filterTable&amp;#8221; is the ID only of the table. The 2 lines i added in the JavaScript file turn the ID into an object.&lt;/p&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: JavaScript filter search in table</title>
      <pubDate>2011-02-25 23:24:45+0100</pubDate>
      <link>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_3</link>
      <comments>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_3</comments>
      <dc:creator>Artur</dc:creator>
      <description>&lt;p&gt;could i get the naked html file too? i have problem too with aplaying it&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: JavaScript filter search in table</title>
      <pubDate>2010-12-09 13:56:23+0100</pubDate>
      <link>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_1</link>
      <comments>http://blog.echarp.org/Re_JavaScript_filter_search_in_table_1</comments>
      <description>&lt;p&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: Can't have 2 different tables on the same page</title>
      <pubDate>2010-11-25 10:09:56+0100</pubDate>
      <link>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page_3</link>
      <comments>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page_3</comments>
      <dc:creator>adrian</dc:creator>
      <description>&lt;p&gt;I think would be a good solution:  &lt;br/&gt;
input.onkeyup = (function(i) {
                         return function() {
                               filterTable(&amp;#8217;filter_&amp;#8217;+i, tables[i]);
                         }
})(i);&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: Can't have 2 different tables on the same page</title>
      <pubDate>2010-08-28 20:08:49+0200</pubDate>
      <link>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page_2</link>
      <comments>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page_2</comments>
      <dc:creator>echarp</dc:creator>
      <description>&lt;p&gt;&lt;p&gt;Super!&lt;/p&gt;
&lt;p&gt;+1 Thanks for the modifications.&lt;/p&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: Can't have 2 different tables on the same page</title>
      <pubDate>2010-08-28 18:54:49+0200</pubDate>
      <link>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page_1</link>
      <comments>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page_1</comments>
      <description>&lt;p&gt;&lt;p&gt;Hi Echarp. Thanks for the answer but after a bit of experimenting I found out that i needed to specify somehow the table to which the textfield applies. Also, I had to do it so that it passes the ID to the filterTable() function. Basically I&amp;#8217;m assigning an ID to the table (if it&amp;#8217;s not already defined, othewise I&amp;#8217;m using that one). 
Also, since a table might already have a class of it&amp;#8217;s own I&amp;#8217;ve modified the code so that is looks for the &amp;#8220;filterable&amp;#8221; substring. I was already using &amp;#8220;sortable resizable&amp;#8221; as a class value.
Last thing, the Array#contains method that I&amp;#8217;m using is an extension for the Prototype lib.&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s the refactored code. I put all of it in a function:&lt;/p&gt;
&lt;p&gt;function initFilterableTables() {
        tables = document.getElementsByTagName(&amp;#8216;table&amp;#8217;);&lt;/p&gt;
for (var t = 0; t &amp;lt; tables.length; t++) {
element = tables[t];
if (!element.attributes[&amp;#8216;id&amp;#8217;]) {
element.setAttribute(&amp;#8220;id&amp;#8221;, &amp;#8220;auto-table-id-&amp;#8221; + t)
}
if (element.attributes[&amp;#8216;class&amp;#8217;] &amp;amp;&amp;amp; element.attributes[&amp;#8216;class&amp;#8217;].value.split(&amp;quot; &amp;quot;).contains(&amp;#8216;filterable&amp;#8217;)) {
var form = document.createElement(&amp;#8216;form&amp;#8217;);
form.setAttribute(&amp;#8216;class&amp;#8217;, &amp;#8216;filter&amp;#8217;);
form.setAttribute(&amp;#8216;id&amp;#8217;, &amp;#8216;filter&amp;#8217;);
var input = document.createElement(&amp;#8216;input&amp;#8217;);
input.setAttribute(&amp;#8216;type&amp;#8217;, &amp;#8216;text&amp;#8217;);
input.style.height = &amp;#8220;2em&amp;#8221;;
input.setAttribute(&amp;#8216;class&amp;#8217;, &amp;#8216;searchtextbox&amp;#8217;);
input.setAttribute(&amp;#8216;id&amp;#8217;, &amp;#8216;searchtextbox&amp;#8217; + t);
input.setAttribute(&amp;#8216;onkeyup&amp;#8217;, &amp;#8216;filterTable(&amp;quot;&amp;#8217; + input.attributes[&amp;#8216;id&amp;#8217;].value + &amp;#8216;&amp;#8220;,&amp;#8221;&amp;#8217; + element.attributes[&amp;#8216;id&amp;#8217;].value + &amp;#8216;&amp;#8220;)&amp;#8217;)
form.appendChild(input);
element.parentNode.insertBefore(form, element);
}
}
&lt;p&gt;}&lt;/p&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Re: Can't have 2 different tables on the same page</title>
      <pubDate>2010-08-28 13:33:00+0200</pubDate>
      <link>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page</link>
      <comments>http://blog.echarp.org/Re_Cant_have_2_different_tables_on_the_same_page</comments>
      <dc:creator>echarp</dc:creator>
      <description>&lt;p&gt;&lt;p&gt;Yes.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m testing it right now, and it only applies to the latest table. This is due to event management and knowing onto which input element the event is associated.&lt;/p&gt;
&lt;p&gt;Are you following this thread? If yes, you could try &lt;em&gt;simply&lt;/em&gt; using the javascript event, assigning a new attribute to the input, something like &amp;#8220;tableNumber&amp;#8221;, which you can use in the &amp;#8220;filterTable&amp;#8221; function in order to apply on the correct table. I&amp;#8217;ll try something this afternoon, and paste here the resulting js&amp;#8230;&lt;/p&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>

