2

I'm using jQuery with TableSorter and QuickSearch plugins. These work fine.

How can I:

  1. dynamically display row numbers for each displayed row?

  2. somewhere on my page, display the total number of displayed rows?

Ayman
  • 11,265
  • 16
  • 66
  • 92

2 Answers2

2
 $('tr:visible').length

Will you give the number of visible rows on the page.

Something along the lines of:

 var rowCount = $('tr:visible').length;
 $('#rowCountDiv').html(rowCount + "rows");

Will write out the number into a div on your page with an id of rowCountDiv

Vincent Ramdhanie
  • 102,349
  • 23
  • 137
  • 192
HurnsMobile
  • 4,341
  • 3
  • 27
  • 39
2

Here's the proper answer. In the PHP use something like this:

echo "Dynamic count: <p id=\"count\"></p>";

Then in the quickSearch add an onAfter function.

onAfter: function() {
    document.getElementById("count").innerHTML=($('tr:visible').length-1);
}

Voila! Now you have a dynamic count that updates whenever the table is searched.

Josh
  • 21
  • 1