...

View Full Version : <table> error



JohnBoy007_2006
05-07-2010, 07:05 AM
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…



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

Dormilich
05-07-2010, 07:22 AM
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)

JohnBoy007_2006
05-07-2010, 07:29 AM
So then s it because innerHTML does not allow tables?



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

abduraooft
05-07-2010, 07:42 AM
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

Dormilich
05-07-2010, 07:48 AM
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.

So then s it because innerHTML does not allow tables?
<script> does not allow tables, but I think that’s due to the " problem.

JohnBoy007_2006
05-07-2010, 09:21 AM
Cheers guuys. so do you think there is a way around this?

Dormilich
05-07-2010, 09:35 AM
content += '<table><tr><td colspan="2"><strong>'+cat.options[cat.selectedIndex].text+'</strong> '+p.options[p.selectedIndex].text+'</td></tr></table>';



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum