Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: <table> error

  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile <table> error

    Hi guys i keep getting an error when i validate: -

    can anyone help please?

    document type does not allow element "table" here
    content += "'<table><tr><td colspan="2"><strong>'+cat.options[cat.selectedInd…

    Code:
    var content="";
    content += "'<table><tr><td colspan="2"><strong>'+cat.options[cat.selectedIndex].text+'</strong> '+p.options[p.selectedIndex].text+'</td></tr></table>'";

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,253
    Thanks
    12
    Thanked 341 Times in 337 Posts
    there is a " too many and the error makes no sense without the context (there are elements, that don’t allow tables inside, but we don’t know, which of these you used or if it is something else)
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New Coder
    Join Date
    May 2010
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So then s it because innerHTML does not allow tables?

    Code:
    document.getElementById('type').innerHTML = content;

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Moving your javascript to an external file of adding CDATA comments around the code would fix it. Read http://javascript.about.com/library/blxhtml.htm
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,253
    Thanks
    12
    Thanked 341 Times in 337 Posts
    Quote Originally Posted by abduraooft View Post
    Moving your javascript to an external file of adding CDATA comments around the code would fix it.
    CDATA is an "invalid" tag in HTML (it would be required in served XHTML, which practically no-one does) and is ignored by HTML parsers, besides it would not make any sense in an external file. a commented comment tag (// <!--, // -->) would suffice, but all recent browsers can differentiate between JavaScript code and HTML tags.
    Quote Originally Posted by JohnBoy007_2006 View Post
    So then s it because innerHTML does not allow tables?
    <script> does not allow tables, but I think that’s due to the " problem.
    Last edited by Dormilich; 05-07-2010 at 07:54 AM.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #6
    New Coder
    Join Date
    May 2010
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers guuys. so do you think there is a way around this?

  • #7
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,253
    Thanks
    12
    Thanked 341 Times in 337 Posts
    Code:
    content += '<table><tr><td colspan="2"><strong>'+cat.options[cat.selectedIndex].text+'</strong> '+p.options[p.selectedIndex].text+'</td></tr></table>';
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •