Clearing all elements from within a named table.

Discussion in 'Javascript' started by Daz, Nov 17, 2006.

  1. Daz

    Daz Guest

    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.
     
    Daz, Nov 17, 2006
    #1
    1. Advertising

  2. 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
     
    Peter Michaux, Nov 17, 2006
    #2
    1. Advertising

  3. Daz

    Daz Guest

    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.
     
    Daz, Nov 18, 2006
    #3
  4. 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
     
    Peter Michaux, Nov 18, 2006
    #4
  5. Daz

    Daz Guest

    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...
     
    Daz, Nov 18, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chris yoker via DotNetMonster.com

    System.IO: best approach for clearing a DIR of all files except .CSV

    chris yoker via DotNetMonster.com, Apr 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    349
    Karl Seguin
    Apr 11, 2005
  2. Jyrki Keisala

    Elements within elements

    Jyrki Keisala, Jun 8, 2005, in forum: XML
    Replies:
    5
    Views:
    431
    William Park
    Jun 15, 2005
  3. Gerald Aichholzer
    Replies:
    2
    Views:
    2,513
    Gerald Aichholzer
    Jun 27, 2006
  4. Replies:
    1
    Views:
    120
  5. Replies:
    4
    Views:
    190
Loading...

Share This Page