[thelist] DOM, removing rows fun [SOLVED]
.jeff
jeff at members.evolt.org
Tue Oct 1 00:31:01 CDT 2002
tom,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Tom Dell'Aringa
>
> As Par Usual - jeff nailed it. Turns out option 1)
> actually doesn't work, when it comes back around to
>
> curID = table.getElementsByTagName("TR").item(x).id;
>
> its gone (even with the decrement) so it throws an
> error, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
hmmm, that doesn't sound right.
i forgot to also decrement the numrows variable if a checked checkbox was found. otherwise a row was being deleted, but the number of rows to loop over wasn't adjusted accordingly.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] then I saw option 2) and realized that in the for
> statement, it had the dynamism of
>
> var x = numrows - 1; x >= 1
>
> which seems to adjust x correctly so no error is thrown.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
rather than adjusting x correctly, the second option loops from the end to the beginning. by doing so it skips the need to change numrows or x since it's already passed over those elements that will be affected.
good luck,
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list