点击添加图片 如“+”  就动态新增table一行
   点击删除图片 如“-”  就动态减少table一行
  现在在页面初始化的时候  我先添加2行
 
   在也面点击添加时  能很顺利的添加一行
   但是我点击删除新增的一行时 却毫无反应   点击删除初始化的2行时却可以成功   这是为什么呢 ?  请各位大虾帮忙想想招!    谁能帮我看看是什么原因?

解决方案 »

  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> 
     var i=2 
    //allCount=1 
    function   insRow()   //增加一行 

            x=ttb98.insertRow(ttb98.rows.length); 
          var  num=document.getElementById('ttb98').value;
            x.ln=i; 
            h2=x.insertCell(0);
            h1=x.insertCell(1); 

            h2.innerHTML="";
            //c1.ln=allCount; 
            h1.innerHTML= "新增图片"+(i-1)+"&nbsp;:<input name='pictitle1"+(i+0)+"' type='text' onfocus=hidethis('pictitle1"+(i+1)+"') value='图片标题' class='logo_inp05' id='pictitle1"+(i+1)+"'>"+"&nbsp;&nbsp;&nbsp;<span class='cRed'>*</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name='picURL1"+(i+0)+"' type='text' value='图片链接' onfocus=hidethis('picURL1"+(i+1)+"') class='logo_inp05' id='picURL1"+(i+1)+"'>&nbsp;&nbsp;&nbsp;<span class='cRed'>*</span><br><br>上传图片<span class='Line22'>&nbsp;&nbsp;:</span><input name='UploadFile1"+(i+0)+"' size=60 type='file' id='UploadFile1"+(i+1)+"'><br><br>图片简介"+(i-1)+"&nbsp;:<br><textarea name='picintro1"+(i+0)+"' cols='45' rows='5' wrap=physical class='logo_inp09' id='picintro1"+(i)+"'></textarea><input   type=button   value= '删除 '   ln= "   +   i   +   "   onclick= 'javascript:delRow(); '> "         i=i+1;  //总计多少行 
           // frm.count.value   =   i; } function   delRow()   //删除一行 

            line   =   parseInt(event.srcElement.ln,10);         if   (line> 0){ 
                    for   (j=1;j <ttb98.rows.length;j++) {      if   (ttb98.rows[j].ln==line)   //
                            { 
                                    ttb98.deleteRow(j); 
                  i--; 
               //   frm.count.value   =     i; 
                            } 
    }
    }

    </script> 
    <form   name=frm> 
    <table   border= "1 "   id=ttb98> 
    <tr> <td   width=100><input   type=button   value=add     onclick= "insRow() "> <input   name=count> </td> </tr> <tr></tr><tr></tr><tr></tr>
    </table> </form> 
    </body> 
    </html> 自己去改进,慢慢调试就知道了
      

  2.   


    <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> 
      

  3.   

     function DelRow(rowIndex) {
            var rowId = "#trParts" + rowIndex;
            if ($(rowId).html() != null) {
                $(rowId).remove();
            } else {
                rowId = "#ctl00_cph_CNEdit_PartEdit_trParts" + rowIndex;
                $(rowId).remove();
            }
        }    var Del = "<img src=\"../Images/btn-remove.gif\" onclick=\"javascript:DelRow(" + maxRowCount + ");\" />";  删除