View Full Version : problem deleteing multiple rows from a table
paula dougherty
09-06-2006, 04:25 PM
Using the following code , I'm trying to delete 2 rows from a table , the first row deletes ok but then I get the error
When trying to do the delete the table contains about 10 rows , I'm trying to delete row 3 , and then row 3 again
displayTbl has no properties
Any ideas..
var displayTbl = parent.expenseDisplay.document.getElementById('expenseDisplayTable');
displayTbl = displayTbl.deleteRow(lineNo);
displayTbl = displayTbl.deleteRow(lineNo);
rlemon
09-06-2006, 09:38 PM
Using the following code , I'm trying to delete 2 rows from a table , the first row deletes ok but then I get the error
When trying to do the delete the table contains about 10 rows , I'm trying to delete row 3 , and then row 3 again
displayTbl has no properties
Any ideas..
var displayTbl = parent.expenseDisplay.document.getElementById('expenseDisplayTable');
displayTbl.deleteRow(lineNo);
displayTbl.deleteRow(lineNo);
var displayTbl = parent.expenseDisplay.document.getElementById('expenseDisplayTable');
displayTbl.deleteRow(lineNo);
displayTbl.deleteRow(lineNo);
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/deleterow.asp
there is no return value from deleteRow()
it is a method you can invoke on an object that supports rows, however you do not need to reset the object every time the method is run
so simply writing
object.deleteRow(0);
object.deleteRow(0);
will delete the first row, then delete the 'new' first row.
right now your
//object = your table object
object = object.deleteRow(n);
//object now = undefined, as you set it to 'null' because there is no return from deleteRow()
// therefore your second 'deleteRow()' call will return an error as there is no object in reference.
anytime when you delete a row, the rowIndexes of the following rows decreases with 1, that is obvious.
Maybe you could try give them display none, instead of removing them. Thus the rowIndexes will not be changed....
rlemon
09-07-2006, 03:58 PM
anytime when you delete a row, the rowIndexes of the following rows decreases with 1, that is obvious.
Maybe you could try give them display none, instead of removing them. Thus the rowIndexes will not be changed....
i'm pretty sure
var displayTbl = parent.expenseDisplay.document.getElementById('expenseDisplayTable');
displayTbl = displayTbl.deleteRow(lineNo);
displayTbl = displayTbl.deleteRow(lineNo);
(the bolded text) is the problem. i tested it and it works.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.