【发布时间】:2019-07-31 03:27:03
【问题描述】:
如何计算过滤后显示的表格行数?
我尝试运行此脚本,但它显示总行数,当前未显示行数:
function CountRows() {
var rowCount = 0;
var table = document.getElementById("filter_table");
var rows = table.getElementsByTagName("tr")
for (var i = 0; i < rows.length; i++) {
if (rows[i].getElementsByTagName("td").length > 0) {
rowCount++;
}
}
var message = "Showing: " + rowCount;
alert(message);
}
位置:http://kissbandstree.com/count_rows.js
没有错误信息。
这是过滤器脚本:http://kissbandstree.com/multifilter.js
这是测试页面:http://kissbandstree.com/artists2.php
我想显示应用过滤器后显示的行数。
这是相关的 PHP/HTML 部分:
<?php
// Fetch all filenames in the kiss_artists directory
$artists = glob('kiss_artists/*.txt');
?>
<table class="standard">
<tr>
<td>
<?php echo"Items in table: " . count($artists) . ". Showing: XXX. Table is sortable. Artists names are links to simple individual pages. Date is when the entry was modified."; ?>
<input id="clickMe" type="button" value="clickme" onclick="CountRows();">
</td>
</tr>
</table>
【问题讨论】:
-
如何隐藏行。使用
display='none'或其他什么? -
好问题。我不完全确定。有一种叫做 row.hide();在 multifilter.js 中。
标签: javascript php filter rows