动态创建行和列? [英] Dynamically create rows and columns?

查看:80
本文介绍了动态创建行和列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够创建一个动态创建子/嵌套列的表。

最多3级。

例如,如果你点击1级列中的拆分,它会自动生成第2级,其中2列嵌套在它。如果再次单击级别1中同一列中的拆分,它会将另一列添加到嵌套在其下的第二级。等等。



这一切都必须存储在数据库中。



我尝试了什么:



我有这块硬编码表:



I need to be able to create a table that dynamically creates child/nested columns.
Maximum is 3 levels.
For example, if you click on 'Split' in a column on level 1, it will automatically generate a second level with 2 columns nested under it. If you click again on 'Split' in the same column in level 1, it will add another column to the 2nd level nested under it. So on and so forth.

This must all be stored in the database.

What I have tried:

I have this block of hard-coded table:

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>
</head>
<body>

<table>
  <tr>
    <th rowspan=3>Month</th>
    <th colspan=3>Savings</th>
    <th rowspan=3>Savings for holiday!</th>
  </tr>
  <tr>
  <td colspan=2>Daily</td>
  <td>Weekly</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>1</td>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
    <td rowspan="2">$50</td>
    <td>$56</td>
    <td>$45</td>
  </tr>
  
  <tr>
    <td>February</td>
    <td>$80</td>
    <td>$34</td>
    <td>$48</td>
  </tr>
</table>

</body>
</html>





但这里的值是固定的。

输出:< a href =https://postimg.org/image/qo6ikfvgf/\"target =_ blank>表

推荐答案

100< / td>
< td rowspan =2>
100</td> <td rowspan="2">


50< / td>
< td>
50</td> <td>


56< / td>
< td>
56</td> <td>


这篇关于动态创建行和列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆