【发布时间】:2019-01-13 23:53:37
【问题描述】:
我在表格列表中显示来自数据库的记录。此外,我在每一行都有一个跟进按钮,如果任何用户点击跟进按钮,则会为特定用户打开一个包含详细信息的弹出窗口。
或任何其他想法来处理这个问题?
我尝试使用类似的东西
<table>
<thead><tr><th></th></tr></thead>
<tbody>
<tr><td></td></tr>
<div style="display:none">
<table>
<thead><tr><th></th></tr></thead>
<tbody>
<tr><td></td></tr>
</tbody>
</table>
</div>
</tbody>
</table>
完整代码
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table border="1">
<thead>
<tr>>
<th>Name</th>
<th>Products</th>
<th>Qty</th>
<th>Order Id</th>
<th>Mobile </th>
<th>Shipping address</th>
</tr>
</thead>
<tbody>
<?php $n=1;
foreach ($cust_personal as $row)
{ $encryption_id=base64_encode($this->encryption->encrypt($row->o_id));//encrpt the id
?>
<tbody>
<tr>
<td><?php echo $n;?></td>
<td><?php echo $row->c_firstname;?> <?php echo $row->c_lastname;?></td>
<td><?php echo $row->o_product_brandname;?></td>
<td><?php echo $row->o_product_qty;?></td>
<td><?php echo $row->o_order_no;?></td>
<td><?php echo $row->c_mobileno;?></td>
<td><?php echo $row->c_s_address;?></td>
<td> <a href="javascript:void(0)" class="table_icon pending" onclick="approve(this)" data-id="<?=$row->o_id;?>"> <span>Pending</span></a>
<a href="<?php echo site_url('Customer_control/get_customer_view?key='.$encryption_id)?>" class="table_icon view">View</a>
<a href="javascript:void(0)" class="table_icon archive" onclick="followup(this)" data-id="<?=$row->o_id;?>">Followup</a>
</tr>
<div id="popup-<?=$row->o_id;?>" style="display: none;" class="class="view_popup_profile">
<div class="profile_content">
<div class="profile_header clearfix">
<table border="1">
<thead><th>sub</th></thead>
<tbody><tr><td>maths</td></tr></tbody>
</table>
</div></div>
</div>
<?php } $n++; ?>
</tbody>
</table>
<script type="text/javascript">
function followup(obj)
{
var id = $(obj).data('id');
//console.log(id);
$("#popup-"+id).show();
}
</script>
</body>
</html>
为什么我需要一个嵌套表,因为当我添加以下代码并单击后续按钮时,我会全屏显示弹出窗口。
</tr>
<div id="popup-<?=$row->o_id;?>" style="display: none;">
<!--more details here-->
</div>
</tbody>
</table>
如果我在弹出窗口中添加了一个表格来显示以下列表,那么它就不起作用了。
</tr>
<div id="popup-<?=$row->o_id;?>" style="display: none;">
<table border="1">
<thead><th>sub</th></thead>
<tbody><tr><td>maths</td></tr></tbody>
</table>
</div>
</tbody>
</table>
css
.view_popup_profile {
position: fixed; /* Stay in place */
z-index: 9; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
-webkit-animation-name: fadeIn; /* Fade in the background */
-webkit-animation-duration: 0.4s;
animation-name: fadeIn;
animation-duration: 0.4s;
}
/* Modal Content */
.profile_content {
position: fixed;
top: 25%;
background-color: #fefefe;
width: 100%;
-webkit-animation-name: slideIn;
-webkit-animation-duration: 0.5s;
animation-name: slideIn;
animation-duration: 0.5s;
max-width: 922px;
margin: auto;
left: 0;
right: 0;
box-shadow: 0 0 15px rgba(0,0,0,.3);
}
/* The Close Button */
.profile_header {
padding: 1px 20px;
background-color: #fafafc;
color: white;
/* min-height: 58px; */
border-bottom: 1px solid #f7f7f7;
display: block;
width: 100%;
}
.profile_header:after {
content: '';
width: 0;
height: 0;
border-left: 17px solid transparent;
border-right: 17px solid transparent;
border-top: 16px solid #f7f7f7;
position: absolute;
}
.profile_body {
padding: 35px 50px;
}
.profile_footer {
padding: 0;
background-color: #fdfdfe;
color: #858585;
}
p{color: #000;}
/* Add Animation */
@-webkit-keyframes slideIn {
from {
top: -500px;
opacity: 0
}
to {
top:25%;
opacity: 1
}
}
@keyframes slideIn {
from {
top: -500px;
opacity: 0
}
to {
top:25%;
opacity: 1
}
}
@-webkit-keyframes fadeIn {
from {
opacity: 0
}
to {
opacity: 1
}
}
@keyframes fadeIn {
from {
opacity: 0
}
to {
opacity: 1
}
}
【问题讨论】:
-
是的,您可以嵌套一个表格,但它必须位于其中一个表格单元格内,介于
<td>和</td>之间或介于<th>和</th>之间。这就是表格的工作方式:所有内容都需要在标题或数据单元格中。 -
@lurker,我尝试使用
我的弹出代码 ,但它在表格中创建了额外的空间。 -
您能告诉我们输出是什么(带有屏幕截图)以及您希望它是什么样子吗?你没有提供细节/细节。
-
@FunkFortyNiner,好的,我会详细解释。请在我更新我的问题的那一刻给我。
-
好的。事实上,请阅读此developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Advanced - 有嵌套表的示例。实际上,我自己就在那个领域lol!我只是在给自己上一门进修课程,就像它一样。是的,即使我有时也不得不自己再读一遍:-)
标签: javascript php jquery html html-table