Clearing all elements from within a named table.

D

Daz

Hello everyone. I have a simple problem which can be solved quite
simply, I am just going about it the wrong way. I would like to wipe
every row from within a named table, but I am not too sure how to do
it.

Each of these rows, are part of a JavaScript Object, which is bound to
the table by objectName.bind('idOfTableToBindTo').

I have tried to destroy the objects themselves, but they still remain.
Perhaps I am doing something wrong... I have tried to make a function
that will loop through all of the 'tr' elements withing the table, and
failed dismally. I know that this can be done, I just can't seem to
figure out how.

As my object can be bound to the table, but still remains when I delete
the variable pointing to the object (which I thought would delete the
object itself).

Is there any way that I can put a function within my object that will
make it destroy itself?

I would assume that an object can't destroy itself, and that it needs
to be done externally, but I am not sure, as I am just assuming.

Please could someone suggest a method I can use to loop through all of
the childElements in a table and delete them?

Also, is there a way to actually delete the object itself, rather than
just the variable pointing to it. It may be the case that it's already
deleting the object, but it doesn't look like it. The more I think
about what it's doing, the more I confuse myself about the entire
issue.

All the best.

Daz.
 
P

Peter Michaux

Hi Daz,
Hello everyone. I have a simple problem which can be solved quite
simply, I am just going about it the wrong way. I would like to wipe
every row from within a named table, but I am not too sure how to do
it.

Can you post a complete example (HTML with JavaScript in head element)
in 30 lines or less that shows how you are trying to do this?

Peter
 
D

Daz

Peter said:
Hi Daz,


Can you post a complete example (HTML with JavaScript in head element)
in 30 lines or less that shows how you are trying to do this?

Peter

Hi Peter. I'm not entirely sure. The class itself is about 250 lines,
as it creates a LOT of DOM elements on-the-fly. Would you like me to
try and summerise it?

Everything works in the code, I just cannot seem to remove or unbind
the elements once they have been added to the table. Once again, I know
this is possible, I just don't know any methods to achieve this, and
those I have tried have failed.
 
P

Peter Michaux

Daz said:
Hi Peter. I'm not entirely sure. The class itself is about 250 lines,
as it creates a LOT of DOM elements on-the-fly. Would you like me to
try and summerise it?

You may sort it out yourself as you do this.

Peter
 
D

Daz

Daz said:
Hi Peter. I'm not entirely sure. The class itself is about 250 lines,
as it creates a LOT of DOM elements on-the-fly. Would you like me to
try and summerise it?

Everything works in the code, I just cannot seem to remove or unbind
the elements once they have been added to the table. Once again, I know
this is possible, I just don't know any methods to achieve this, and
those I have tried have failed.

Ok, I have an update to my previous post. I am using the Web Developer
Extension for Firefox, and I have spotted something rather odd. As I
mentioned before, my objects are created within a table row, and bind
to a hard-coded table in my document. I have enabled table and cell
outlining with the Web Developer Extension, and the table for that my
objects are bound to is outlines, as are the newly appended rows.
However, the old rows are non-existent (which is a good thing), but the
new rows are inserted from the point where the last rows ended. So I
have a blank section at the top of my table. Each time I press the
submit button to make the calculations, delete the right elements and
then make new objects and append them to the table, the new objects are
always inserted at the point where the old objects ended before they
were deleted.

Basically, Each time I press the submit button, the old
objects/elements are cleared, but the new ones are shifted down the
table. If I push the submit button three times, the new rows disappear
from the bottom of the page...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top