表格增加一列,能自动生成序号?

http://img.mukewang.com/5918fd400001869c03210102.jpg

实现代码:

<table class="table-detail">

<tr>

<th>名称</th>

<th>总计</th>

</tr>

</table>

<script type="text/javascript">

var baseData = [

{"name":"昌大","total":"1000"},

{"name":"西江红","total":"2000"}

];

window.onload = function() {

var mytable = document.getElementsByTagName('table')[0];

for(var i = 0; i < baseData.length; i++) {

var tr = mytable.insertRow(mytable.rows.length);

var obj = baseData[i];

for(var p in obj) {

var td = tr.insertCell(tr.cells.length);

td.innerText = obj[p];

}

}

}

</script>


但是,我想要增加一列,自动生成序号,如下图。

http://img.mukewang.com/5918fd400001c8a803260106.jpg


慕姐4266817
浏览 2434回答 3
3回答

ruibin

增加一列,alter table t1 add column 序号 int auto_increment unique first;
打开App,查看更多内容
随时随地看视频慕课网APP