【发布时间】:2014-01-13 16:59:00
【问题描述】:
我有 mysql 隐藏的嵌套表。单击黄色箭头时,嵌套表显示/隐藏。问题是我的表格行坏了。
就像上图一样,表格的另一行已损坏。这有什么问题?
<?php
echo'<table id="tfhover" cellspacing="0" class="tablesorter">
<thead>
<tr>
<th style="display:none;"></th>
</tr>
</thead>';
echo'<tbody>';
$i=1;
while($row = $result->fetch_assoc()){
echo'<tr>
<td align="center" id="none">';
if (empty($row['qtysum'])){
echo '<a href="javascript:void(0)"></a></td>';
} else {
echo '<a onclick="toggleTable(this);" data-counter="'.$rowid.'" href="#"><img src="images/arrow_right.png" border="0" width="15" height="15" title="Show List of '.$row["item_name"].'"></a></td>';
}
echo'<td>'.$i++.'</td>
</tr>';
echo'<tr>';
echo'<table id="loginTable'.$rowid.'" border="1" align="center" style="display:none">
<thead>
<tr>
<th></th>
</tr>
</thead>';
echo'<tbody>';
$i=1;
while($row = $result1->fetch_assoc()){
echo'<tr>
<td>'.$i++.'</td>
</tr>';
}
echo "</tbody></table></tr>";
}
}
echo "</tbody></table>";
?>
这是我的显示/隐藏表脚本。
<script>
function toggleTable(link) {
var elem=document.getElementById("loginTable" + link.getAttribute('data-counter'));
var hide = elem.style.display =="none";
if (hide) {
elem.style.display="table";
} else {
elem.style.display="none";
}
return false;
}
</script>
如果有<tr><td> </td></tr>
【问题讨论】:
-
查看您的页面源代码并发布由 PHP 代码构建并呈现出与您预期不同的 HTML 标记。这会让我们更容易发现问题。
标签: php jquery mysql html-table