JQuery, Find results in table column
<p>Im trying to find the results in a table column if its set in my function below, most of this was setup by someone else, ive just added some extras into it, my final one is searching 1 column only by name set in the thead but alas in its current edition nothing happens at all :|</p>

<p>thanks for any help</p>

USAGE

<pre><code>&lt;a href='javascript:searchTable("Bob", "table",1,"Name");'&gt;Test&lt;/a&gt; 
</code></pre>

TABLE

<pre><code>    &lt;table id="table" class="table"&gt;
       &lt;thead&gt;
          &lt;tr&gt;
            &lt;th id="blank"&gt;&amp;nbsp;&lt;/th&gt;
            &lt;th id="Name"&gt;Name&lt;/th&gt;
            &lt;th id="Dept"&gt;Department&lt;/th&gt;
            &lt;th id="JobTitle"&gt;Job Title&lt;/th&gt;
          &lt;/tr&gt;
       &lt;/thead&gt;
       &lt;tbody&gt;
          &lt;tr&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;Bob&lt;/td&gt;
            &lt;td&gt;IT&lt;/td&gt;
            &lt;td&gt;IT Support&lt;/td&gt;
          &lt;/tr&gt;    
          &lt;tr&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td&gt;Fred&lt;/td&gt;
            &lt;td&gt;Finance&lt;/td&gt;
            &lt;td&gt;Finance Man&lt;/td&gt;
          &lt;/tr&gt;     
       &lt;/tbody&gt;
   &lt;/table
</code></pre>

FUNCTION

<pre><code>function searchTable(inputVal, tablename,starts, column) {
    var table = $(tablename);
    table.find('tr:not(.header)').each(function (index, row) {
        if (column != '') {
            //Columnname
            var Cells = $(row).find('td').eq(column);
        } else {
            //AllCells
            var Cells = $(row).find('td');
        }
        if (Cells.length &gt; 0) {
            var found = false;
            Cells.each(function (index, td) {
                if (starts == 1) {
                    var regExp = new RegExp((starts ? '^' : '') + inputVal, 'i');
                } else {
                    var regExp = new RegExp(inputVal, 'i');
                }

                if (regExp.test($(td).text())) {
                    found = true;
                    return false;
                }
            });
            if (found == true) $(row).show().removeClass('exclude'); else 
            $(row).hide().addClass('exclude');
            }
        });
    }
</code></pre>
