event.srcElement.ln???是什么东西? 应该是 event.srcElement.id 吧?  把全部代码贴出来,就知道你的病根了,

解决方案 »

  1.   

    你的每行的ln属性有没有动态变化阿?
    比如你删除了两行。那你的ln是不是相应的减少了??重新排列一下你的ln
    至少我在上面的程序中没有看到你的ln 的变化
      

  2.   

    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=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>try,try</td></tr>
    </table>
    <input type=button value=add  onclick="addTrafficeRow()"><input name=trafficCount>
    </form>
    </body>
    </html>