NEED YOUR HELP W/ Add/Delete Table Rows

From: Karen (bambina_carina_at_yahoo.com)
Date: 03/18/04

  • Next message: N. Graves: "Using Office Components on IIS 5.0"
    Date: 17 Mar 2004 17:50:50 -0800
    
    

    Hi there,
    Can you please help me with this:
    I've been able to insert new cell into my table (using insertcell()).
    I always insert new cells at the end of the existing table. At the end
    of each row, a delete button is added as well to let the user delete
    the corresponding row.

    no my question is: how can I resize my table rows so that when the
    user clicks on the delete button the right row is sent to my delete
    method. Actualy, if the user adds more that one row, deleted row index
    are not adjusted if more that row is deleted.

    here<s my code:
    function InsertNewRow(){
        
        if (document.all)
         MyTable= document.all.TblMyTable;
       else
         MyTable= document.getElementById('TblMyTable');

         var row = MyTable.insertRow(MyTable.rows.length);
         var Cell1 = row.insertCell(0);
         var Cell2 = row.insertCell(1);
         var Cell3 = row.insertCell(2);
        
      for (var i= 0; i< MyTable.length; i++)
     {

    Cell1.innerHTML= '<td>'+ (i+1)+ '</td>';
    Cell2.innerHTML= '<><input type="text" name="input1" value=""</td>';
    Cell3.innerHTML= '<Td><input type="button"
    onClick="DeleteThisRow('+row.rowIndex+');"
    name="Delete"value="Delete"</td>';
    }
    }
    function DeleteThisRow(RowIndex)
    {
      if (document.all)
         MyTable= document.all.TblMyTable;
       else
         MyTable= document.getElementById('TblMyTable');

       MyTable.deleteRow(RowIndex);
    }

    As u see the row index sent to the delete method is right only if it's
    the first time deleting row, after 2,3 times it's not the right
    one....
    Is it possible to do this differently?? is possible to display the
    table after deleting the row with the rights rows indexes???

    thanks a lot


  • Next message: N. Graves: "Using Office Components on IIS 5.0"
    Loading