table的insertRow和deleteRow的问题 event.srcElement.ln???是什么东西? 应该是 event.srcElement.id 吧? 把全部代码贴出来,就知道你的病根了, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的每行的ln属性有没有动态变化阿?比如你删除了两行。那你的ln是不是相应的减少了??重新排列一下你的ln至少我在上面的程序中没有看到你的ln 的变化 try:<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=1allCount=1function 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> <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>try,try</td></tr></table><input type=button value=add onclick="addTrafficeRow()"><input name=trafficCount></form></body></html> google maps api v3版 画路径时加载数据越来越慢 帮忙改个JS特效,主要是浏览器兼容问题! 大家用js+php的时候用什么ide ID未定义? 关于ActionScript3和JavaScript 在JS中,时间如何相加谢谢大家 如何根据select改变embed里的src音乐地址 如何作 pdf文件被显示完成后就把它删除,请高手指点。 高分求XMLSpyFomEditor的用法 是否可以用javascript改变form的enctype属性值 网页中,隐含字段的赋值能否赋成数组啊? 如何打开一个网页
比如你删除了两行。那你的ln是不是相应的减少了??重新排列一下你的ln
至少我在上面的程序中没有看到你的ln 的变化
<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> <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>try,try</td></tr>
</table>
<input type=button value=add onclick="addTrafficeRow()"><input name=trafficCount>
</form>
</body>
</html>