Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
My instructor wants for us to use the documentwrite.ln for a very simple html table with 3 columes and 2 rows. I can create the table fine with the html but can not get the javascript to work. He did not give us any good examples for the use of document.writeln on a table, just regular text. Here is what I have been trying, I have been looking things up online trying to figure this out.

XML
<html>
<head>
<title>Assignment1.2
<body>
<script type"text/javascript">
<!--
<table cellspacing="5" border="2">
document.write (" <tr><td>");
document.write (" <th>Course");
document.write (" <th>Name");
document.write (" <th>Focus");
document.write (" </tr>");
document.write (" <tr>");
document.write (" <td>CST 214</td>");
document.write (" <td>JavaScript Programming</td>");
document.write (" <td>Client-Side Web Programming</td>");
document.write (" </tr>");
document.write (" <tr>");
document.write (" <td>CST 217</td>");
document.write (" <td>Web Server Programming</td>");
document.write (" <td>Server-Side Web Programming</td>");
document.writeln (" </tr>");
 </table>
// -->
</script>
</body>
</html>
Posted
Comments
TheyCallMeMrJames 12-Sep-10 0:35am    
+5 because you stated clearly your problem, showed what you tried. Use this as a reference: http://www.w3schools.com/jsref/default.asp

1 solution

You want to move your table element outside of your script tags:

XML
<table cellspacing="5" border="2">
<script type"text/javascript">
<!--
        document.write("...");
// -->
</script>
</table>


Good luck with your assignment.

Cheers.
 
Share this answer
 
Comments
Doris Christian 12-Sep-10 6:37am    
Thanks a bunch, that worked!
TheyCallMeMrJames 12-Sep-10 12:37pm    
No worries...fix that first tr/td before your headers and you should be off to the races. Cheers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900