`
tanglong8848
  • 浏览: 67071 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

动态添加删除表格

 
阅读更多

<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<meta name= "GENERATOR " content= "Microsoft FrontPage 4.0 ">
<meta name= "ProgId " content= "FrontPage.Editor.Document ">
<title> try </title>
</head>
<body>
<script>
allTrafficCount=1
allCount=1
function addTrafficeRow() //增加一行
{
newRow=trafficeList.insertRow(trafficeList.rows.length);
newRow.id= "tradt ";
newRow.ln=allTrafficCount;

c1=newRow.insertCell(0);
c1.id= "tradtRow ";
c1.ln=allCount;
c1.innerHTML= " <input type=text name= 'traffic ' size=40 maxlength=200> &nbsp;&nbsp; <input type=button value= '删除 ' ln= " + allTrafficCount + " onclick= 'javascript:delTrafficeRow(); '> "

allTrafficCount++; //总计多少行
frm.trafficCount.value = allTrafficCount;

}

function delTrafficeRow() //删除一行
{
line = parseInt(event.srcElement.ln,10);

if (line> 0)
for (i=1;i <trafficeList.rows.length;i++)

if (trafficeList.rows[i].ln==line) //
{
trafficeList.deleteRow(i);
allTrafficCount--;
frm.trafficCount.value = allTrafficCount;
}
}
</script>
<form name=frm>
<table border= "1 " id=trafficeList>
<tr> <td width=100> test </td> </tr>
</table>
<input type=button value=add onclick= "addTrafficeRow() "> <input name=trafficCount>
</form>
</body>
</html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics