我们可以在``之后使用嵌套表吗?

时间:2018-08-07 01:08:28

标签: javascript php jquery html5 html-table

我正在表列表中显示数据库中的记录。另外,我在每行中都有一个跟踪按钮,如果有任何用户单击跟踪按钮,则会为特定用户打开一个包含详细信息的弹出窗口。

还有其他解决此问题的想法吗?

我试图使用类似这样的东西

<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;?>&nbsp; <?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>

这是我得到的输出。 https://colab.research.google.com/

为什么我需要一个嵌套表,因为当我添加以下代码并单击“跟进”按钮时,我会在全屏幕上看到弹出窗口。

</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
}
}

2 个答案:

答案 0 :(得分:2)

您当然可以制作嵌套表。使所有内容都像常规表一样,直到td标记为止。在其中,制作表格标签和所有内容。首先,您要做的是缩进不良(我在JSFiddle中整理过

这是表格的单元格的样子:

<td>
    <table>
      <thead>
        <th>sub</th>
      </thead>
      <tbody>
        <tr>
          <td>maths</td>
        </tr>
      </tbody>
    </table>
</td>

您也可以使用colspan和rowspan(其结果相似)来防止被复杂的设计所迷惑。

<tr>
 <td rowspan = 2>10</td>
 <td> 10 </td>
</tr>
<tr>
 <th>sub</th>
</tr>
<tr>
 <td>math>
</tr>

答案 1 :(得分:0)

是的,您当然可以在表中添加表,但是请记住将它们添加到<td></td>的表单元格中。下面是参考链接,不要害怕尝试!
ref:https://www.yourhtmlsource.com/tables/nestingtables.html
(p.s ..如果您担心要在单元格中创建多余的空间,则可以在CSS中修改单元格或嵌套表的样式,例如调整边距或填充。
插件:
您可以尝试使用jquery从点击的链接中提取data,然后从链接中删除onclick=followup(this)

将其添加到脚本中并尝试:

$(".archive").on('click',function(){
        var id = $(this).data('id');
        $("#popup-"+id).show();
})
相关问题