[thelist] DOM, removing rows fun

Tom Dell'Aringa pixelmech at yahoo.com
Mon Sep 30 19:22:01 CDT 2002


--- meretal <joelstevenson at mac.com> wrote:
> >
> >Doing the second suggestion kind of works, in fact if I only
> select
> >one in the list it works perfect. But when I select more than one,
> it
> >only gets me half.
>
> You also shouldn't increment 'x' if you've removed a row.  As it is
> 'x' is essentially jumping ahead one index slot because the removed
> row no longer exists.

Ok, here is where I'm at -- tried what Joel said..still getting an
endless loop, even if I remove the numrows = numrows - 1

---
function tempDelete()
{
	var table = document.getElementById("mydocs");
	var tbody = document.getElementById("doclist");
	var numrows = table.getElementsByTagName("TR").length;

	x = 0;

	while(x < numrows)
	{
		if(!x == 0) // don't do any operations on the delete checkbox.
		{
		curID = table.getElementsByTagName("TR").item(x).id;
		CBID = "cb_" + curID;
		curCB = document.getElementById(CBID);

			if(curCB.checked == true)
			{
				row = table.getElementsByTagName("TR").item(x);
				tbody.removeChild(row);
				numrows = numrows - 1;
			}
			else
			{
			x++;
			}
		}

	}
}
--------

I've hit the wall here..any other suggestions?

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



More information about the thelist mailing list