Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 
<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 11-Sep-10 13:34pm
Comments
TheyCallMeMrJames at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You want to move your table element outside of your script tags:
 
<table cellspacing="5" border="2">
<script type"text/javascript">
<!--
        document.write("...");
// -->
</script>
</table>
 
Good luck with your assignment.
 
Cheers.
  Permalink  
Comments
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 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 185
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 12 Sep 2010
Copyright © CodeProject, 1999-2014
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