1 回答

TA贡献1789条经验 获得超10个赞
好的,现在我的一个朋友通过在我的 tr 中添加一键解决了这个问题。如果你现在点击表格中的一行,你会看到一个带有该行描述的弹出窗口。下表代码:
// Head of the table
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>category</th>
<th>Skills</th>
<th>competenties</th>
<th>date added</th>
<th>Email uploader</th>
<th>Visable</th>
<th>Approve</th>
<th>Disapprove</th>
</tr>
</thead>
// Data of the table
$data = "<p>".$row['Descriptie']."</p>"; //data is the Description of the row you send it to your modal by using \"OpenModalWith('$data')"
<tr onclick=\"OpenModalWith('$data', '".$row["Name"]."');\" data-toggle='modal' value=".$row["ID"]." data-target='#myModal' id=".$row["ID"].">
<td>" . $row["ID"]. "</td>
<td>" . $row["Name"]. " </td>
<td>" . $row["Category"]. " </td>
<td>" . $Skill. " </td>
<td>" . $Competences. " </td>
<td>" . $row["DateAdded"]. " </td>
<td>" . $row["EmailUploader"]. " </td>
<td> ";
这是模态( row['description'] 是该行的描述):
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<p><?php echo $row2['Descriptie'];?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
在我的 javascript 代码中,他说获取 elementbyID 因此,例如 myModal(myModal 是我的模态 ID)
function OpenModalWith(content, title){
modal = document.getElementById("myModal");
modaltitle = modal.getElementsByClassName("modal-title")[0];
modalbody = modal.getElementsByClassName("modal-body")[0];
modalbody.innerHTML = content;
modaltitle.innerHTML = title;
}
- 1 回答
- 0 关注
- 128 浏览
添加回答
举报