Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Clearing all elements from within a named table.

Reply
Thread Tools

Clearing all elements from within a named table.

 
 
Daz
Guest
Posts: n/a
 
      11-17-2006
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.

 
Reply With Quote
 
 
 
 
Peter Michaux
Guest
Posts: n/a
 
      11-17-2006
Hi Daz,

Daz wrote:
> 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

 
Reply With Quote
 
 
 
 
Daz
Guest
Posts: n/a
 
      11-18-2006

Peter Michaux wrote:

> Hi Daz,
>
> Daz wrote:
> > 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


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.

 
Reply With Quote
 
Peter Michaux
Guest
Posts: n/a
 
      11-18-2006
Daz wrote:
> Peter Michaux wrote:
>
> > Hi Daz,
> >
> > Daz wrote:
> > > 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

>
> 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

 
Reply With Quote
 
Daz
Guest
Posts: n/a
 
      11-18-2006

Daz wrote:

> Peter Michaux wrote:
>
> > Hi Daz,
> >
> > Daz wrote:
> > > 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

>
> 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...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newb: recurse over elements children and disable all form elements SteveKlett@gmail.com Javascript 4 09-20-2006 07:42 AM
XSLT: iterating all child elements and accessing homonymous childrenin sibling elements Gerald Aichholzer XML 2 06-27-2006 03:46 PM
To allow left click only on some elements of web page NOT all elements vikas.khengare@gmail.com Javascript 1 05-31-2006 09:26 AM
Elements within elements Jyrki Keisala XML 5 06-15-2005 04:58 PM
[XML Schema] Identically named elements of different type Stanimir Stamenkov XML 9 01-26-2005 04:34 PM



Advertisments