Click here to Skip to main content
11,496,146 members (678 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: Javascript
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.

<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>");
// -->
Posted 11-Sep-10 13:34pm
TheyCallMeMrJames at 12-Sep-10 0:35am
+5 because you stated clearly your problem, showed what you tried. Use this as a reference:

1 solution

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

<table cellspacing="5" border="2">
<script type"text/javascript">
// -->

Good luck with your assignment.

Doris Christian at 12-Sep-10 6:37am
Thanks a bunch, that worked!
TheyCallMeMrJames at 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)

  Print Answers RSS
0 RyanDev 230
1 Sergey Alexandrovich Kryukov 114
2 Richard Deeming 100
3 OriginalGriff 89
4 Mostafa Asaduzzaman 59
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 12 Sep 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100