使用javascript对表格进行动态修改
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function addrow(){
var tb = document.getElementById("tab");
var num = tb.rows[0].cells.length; //表格的列的数目
var newrow = tb.insertRow(tb.rows.length); //插入新行
var Cells = newrow.cells;
for(var i = 0 ;i<num;i++){
var newcell = newrow.insertCell(Cells.length); //插入新列
newcell.align = "center";
newcell.innerHTML=tb.rows.length-1;
}
}
</script>
</head>
<body>
<input type="button" name="Submit" value="添加" οnclick="addrow();" />
<table id="tab" width="445" border="1">
<tr>
<th width="68" scope="col">编号</th>
<th width="42" scope="col">姓名</th>
<th width="67" scope="col">登录名</th>
<th width="49" scope="col">身份</th>
<th width="85" scope="col">创建时间</th>
<th width="94" scope="col">登录时间</th>
</tr>
</table>
</body>
</html>