Yes, you can dynamically remove rows in a table using the removeChild() function:
// Remove all rows that have a certain dirty_word in them
var oTable = document.getElementById('table_name');
var arRows = oTable.childNodes[0].childNodes;
var bIE = navigator.userAgent.indexOf("MSIE") != -1 ? true : false;
for (var i = 0; i < arRows.length; i++)
{
var sInner;
if (bIE)
sInner = arRows[i].innerText.toLowerCase();
else
sInner = arRows[i].textContent.toLowerCase();
if (sInner.indexOf('dirty_word') != -1)
oTable.childNodes[0].removeChild(arRows[i]);
}
If you just want to hide the rows, so that you could show them again later, there is an example here:
http://www.morecavalier.com/index.php?item=quickfilter
: : Hi.
: :
: : I have a questions.
: :
: : I have an HTML table with a given number of rows , let's say 10 for this questions. With 2 cells per row.
: :
: : I know that I can replace the contents of each cell via javascript (getElementById).
: :
: : However, can I delete rows via javascript? I have a situation where sometimes I will need to have less (or more) rows than the currently displayed?
: :
: : Thanks in advance for any comments.
: :
: : yd
: :
: It is possible to write new code into a page using the document.write() command in javascript. I don't know if it is possible to delete code.
: