【发布时间】:2017-03-23 06:47:20
【问题描述】:
我有一个按钮,当我按下它时,我必须在我的表格中显示一个隐藏的列。但我的问题是我只显示一行。
<a href="#" class="btn-xl btn-default" id="btn_callkit" onclick="call();return false;" style="width: 150px;color: white;">KIT</a>
<table id="example0" class="table table-striped">
<br/>
<thead>
<tr>
<th id="kit_head" style="display:none;">KIT</th>
<th>Material</th>
<th>Info</th>
</tr>
</thead>
<?php
$rol = mysql_query("SELECT * from pg WHERE pg.dataset = 2 ");
if (mysql_num_rows($rol) != 0) {
while($item = mysql_fetch_array($rol)) {
$id = $item['id'];
$info = $item['info'];
$code = $item['lote_code'];
?>
<tr id="infodata_<?=$id;?>">
<td id="line" style="display:none;">
<div class="checkbox checkbox-circle" style="text-align:center;margin-top:40px;">
<input id="check_<?=$id;?>" type="checkbox">
<label for="check_<?=$id;?>">
</label>
</div>
</td>
<td><?php echo $info;?></td>
<td><?php echo $code;?></td>
</tr>
<? }} ?>
</tbody>
</table>
我的 Javascript 有这个代码:
function call()
{
document.getElementById('kit_head').style.display = 'block';
document.getElementById('line').style.display = 'block';
}
我可以做些什么来显示我的数据库里面的所有行?
【问题讨论】:
-
尝试使用
class而不是id,例如使用<th class="toggleColumn"和document.getElementByClass('toggleColumn') -
您正在专门更改 ID 为“Line”和“kit_head”的第一个元素的显示。相反,您可以使用
包装
标签: javascript php html-table