#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    178
    Rep Power
    12

    Angry Node cannot be inserted at the specified point in the hierarchy


    Hi,
    can someone point out the error in my ways with the script at http://www.alphaworks.co.uk/test/add2.html ?

    It gives a "Node cannot be inserted at the specified point in the hierarchy" error relating to line 26.

    I can't see what I'm doing wrong, it would seem a valid thing to do. I've searched on the error but can't see anything which applies to my problem.

    Thanks,
    Geoff
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Posts
    1,014
    Rep Power
    15
    Look carefully at your newTD function. What are you creating and returning from there? Oops!

    Hope this helps,
    Jeroen
  4. #3
  5. Application is what Divides Us
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Dec 2002
    Location
    Titusville, FL
    Posts
    2,179
    Rep Power
    59
    It may be because the parentNode is not what think.
    Code:
    // This is what the browser assumes as the table hierachy
    // even if you don't include the thead, tbody, or tfoot tags
    <table>
      <thead>
        <tr><th></th></tr>
      </thead>
      <tbody>
        <tr><td></td></tr>
      </tbody>
      <tfoot>
        <tr><th></th></tr>
      </tfoot>
    </table>
    Add ... I'm pretty sure you're going to get TBODY.
    Code:
    window.alert(insert_press_before_here.parentNode.tagName);
    Download [ Fx | Op ] Validate [ Markup | Css ]
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    178
    Rep Power
    12
    Originally Posted by jerom
    Look carefully at your newTD function. What are you creating and returning from there? Oops!

    Hope this helps,
    Jeroen
    Very helpful, silly mistake!

    Thanks
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    178
    Rep Power
    12
    Originally Posted by jsKid
    It may be because the parentNode is not what think.
    Code:
    // This is what the browser assumes as the table hierachy
    // even if you don't include the thead, tbody, or tfoot tags
    <table>
      <thead>
        <tr><th></th></tr>
      </thead>
      <tbody>
        <tr><td></td></tr>
      </tbody>
      <tfoot>
        <tr><th></th></tr>
      </tfoot>
    </table>
    Add ... I'm pretty sure you're going to get TBODY.
    Code:
    window.alert(insert_press_before_here.parentNode.tagName);
    Hi,
    while you're right about the parentNode of the <tr> element being <tbody> and not <table> I don't think this actually caused the problem in this case. I have changed the names of the variables to match this though.

    Thanks,
    Geoff

IMN logo majestic logo threadwatch logo seochat tools logo