DOM exception 8

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sdustinh
    New Member
    • Sep 2007
    • 26

    DOM exception 8

    Alright, I've had this problem for a while, but haven't been able to figure out what's causing it. After searching forever looking through manuals and such, I think I found the answer though I don't know how to solve it.

    First, here is the code:

    [CODE=javascript]var thetable = document.getEle mentById(theHd) ;
    var oldrow = document.getEle mentById('nopar t');
    if (oldrow) {thetable.tBodi es[0].removeChild(ol drow);}[/CODE]

    theHd switches between table ID's (hdpart-1, hdpart-2, hdpart-3). There is one row in each table that needs to be removed. When it comes time to remove that row with the code above, it will work with the first table (hdpart-1), but will not remove anything from the other tables and spits out a DOM exception 8 error.

    I searched all over for the answer and found the following: Link 1 , Link 2.

    Alright, so it's spitting out a NOT_FOUND_ERR, but how do I solve this? I can't really understand why it would remove the row from the first table only, but ignores it in all of the other tables? Thanks.
    Last edited by gits; Oct 4 '07, 04:54 PM. Reason: fix code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    could you please post the simplified html-tables that relates to this problem? ... and the code that loops through the tables and tries to remove the 'oldrow' ... so that we may have a closer look at it?

    kind regards

    Comment

    • sdustinh
      New Member
      • Sep 2007
      • 26

      #3
      Sure, it's pretty simple.

      Code:
      <table id="hdpart-1">
      	<tbody>
      		<tr>
      			<td colspan="9">Remove Me</td>
      		</tr>
      	</tbody>
      </table>
      <table id="hdpart-2">
      	<tbody>
      		<tr>
      			<td colspan="9">Remove Me</td>
      		</tr>
      	</tbody>
      </table>
      <table id="hdpart-3">
      	<tbody>
      		<tr>
      			<td colspan="9">Remove Me</td>
      		</tr>
      	</tbody>
      </table>
      I'm using javascript to go through the specific table. If it's the first entry to be added to the table, I want it to remove the Remove Me cell, and replace it with the other information. Right now it acts how it is supposed to for the first table (hdpart-1), but if i try to add information to the other tables, it leaves the Remove Me row and adds the information below it. Also, if I go to add the information on another table, say hdpart-2, before adding it to the first one (hdpart-1) nothing happens. It spits out a DOM Exception 8 error.

      The code I'm using to remove the row from the table before adding the new information is:

      [CODE=javascript]var thetable = document.getEle mentById(theHd) ;
      var oldrow = document.getEle mentById('nopar t');
      if (oldrow) {thetable.tBodi es[0].removeChild(ol drow);}[/CODE]

      theHd is where 'hdpart-1' 'hdpart-2' 'hdpart-3' is passed. This will change according to which table information will be added to. I know it's this error that is messing it all up, but I just can't figure out why it's only working properly on the first table and not the others. It's something to do with the incorrect node, but I have no idea how to solve it.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        hi ...

        i'm not sure if i could understand it correctly ... but the tables have no row with the id = 'nopart'? so you should get an error here?:

        [CODE=javascript]var oldrow = document.getEle mentById('nopar t');[/CODE]
        kind regards

        Comment

        • sdustinh
          New Member
          • Sep 2007
          • 26

          #5
          BAH! Yes, I am sorry. Each row does have an id of 'nopart'. Sorry, I completely forgot.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            hmm ...

            i think that could be the problem ... you remove a node with id='nopart' the first time. and getElementById will always find the first ocurring obj. since an id has to be unique ... the dom is corrupted ... so try using unique ids or use an attribute that you may identify for your purpose ...

            kind regards

            Comment

            • sdustinh
              New Member
              • Sep 2007
              • 26

              #7
              OH WOW! I cannot believe I missed that, I know better than that. Haha, thanks! I've been trying to figure that out for 3 days now.

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                hi :)

                ... tell me if you encounter more problems with that or if the problem is resolved with this? ...

                post back anytime you have more questions ...

                kind regards
                gits

                Comment

                Working...