Topic: [DOM] Removing nodes. Pages that link to <a href="https://ozoneasylum.com/backlink?for=10787" title="Pages that link to Topic: [DOM] Removing nodes." rel="nofollow" >Topic: [DOM] Removing nodes.\

 
Author Thread
OMERA
Bipolar (III) Inmate

From: France
Insane since: Mar 2000

IP logged posted posted 08-11-2002 01:20 Edit Quote

Ok, here I face another problem.

Here I have a standard compliant document with that part:

code:
<table id="bag">
<tr>
<td>Knife</td>
<td>0.2</td>
</tr>
<tr>
<td>rope</td>
<td>2</td>
</tr>

</table>



Fact is that I want to remove those 2 lines from the table and add some others.
Here is the code I use:
<edit> getObj method is a convenient method to replace getElementById... </edit>

code:
var tree = getObj('bag');
var arr = tree.getElementsByTagName("tr");

for(i=0; i<arr.length; i++)
{
alert("Removing node " + arr[i].nodeName);
getObj('bag').removeChild(arr[i]);
}


The alert message is ok: it tell me that i am removing a TR node.
BUT!
The next line throw an exception "Node not found" (peeked into Mozilla javascript window, those shitty
ie just say "error" without further explanation)

I don't understand...

Trying another approach, I changed the problematic line with this one:

code:
getObj('bag').removeChild(getObj('bag').firstChild);



THIS TIME, the function works perfectly under Mozilla 1.1, removes line by line and let me add other lines after; but behaves strangely in ie: the first call remove all the TR in one strike!

Did I missed something???? Any DOM expert around here?

Thanks!!!!!!!!!

[This message has been edited by OMERA (edited 08-11-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

IP logged posted posted 08-11-2002 09:57 Edit Quote

Take a look at this: http://www.xs4all.nl/~ppk/js/tablefun.html


Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

IP logged posted posted 08-11-2002 12:20 Edit Quote

then check this out: http://www.brainjar.com/dhtml/domviewer/


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

IP logged posted posted 08-11-2002 12:53 Edit Quote

Petskull, Mozilla already comes with advanced DOM Inspector and JavaScript Debugger...


Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

IP logged posted posted 08-11-2002 19:37 Edit Quote

oh....well.... neato...


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu