Jamie Peregrym Jamie Peregrym - 1 year ago 65
HTML Question

Filter table using values in specific column

I am trying to filter a table using javascript to only show rows which have more then 5 seeders. Here is a link to a JSFiddle with an example of the table.

http://jsfiddle.net/xQB4Z/566/

Example of one row:

<td align=left width=500><NOBR><a href="download.php?id=1241487&SSL=1"><img style="position: relative; top: 2px;" src="themes/classic/pic/download.gif.pagespeed.ce.6SI31hDpjb.gif" border="0"></a>&nbsp;<a class="index" href="details.php?id=1241487&amp;hit=1">CENTOS 4</a> (<b><font color="red">NEW!</font></b>)</NOBR><br/><font size=1 color='666666'><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Uploaded 13 m, 44 seconds after pre</i></font></td>
<td align="right"><b><a href="details.php?id=1241487&amp;hit=1&amp;filelist=1">78</a></b></td>
<td align="right">0</td>
<td align=center><nobr>2016-08-17<br/>23:23:27</nobr></td>
<td align=center>----</td>
<td align=center>6.64<br/>GB</td>
<td align=center>----</td>
<td align="right"><span class="green">2</span></td>
<td align="right"><span class="green">2</span></td>
</tr>

Answer Source

You can do something like this:

Array.from(document.querySelectorAll("tr")).forEach(function(v, k){
    var seeders = v.querySelectorAll("td")[8].textContent;
    if(seeders < 5){
        v.style.display = "none";
    }
});

What this will do is to check the content of 9th column in each row and if the value in this column is smaller then 5, hide the row.

DEMO

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download