Connecting Tech Pros Worldwide Help | Site Map

Outputting a Table in javascript

  #1  
Old August 26th, 2008, 02:25 PM
Newbie
 
Join Date: Aug 2008
Location: Champaign
Posts: 2
I am new to this forum and to javascript I have something due for class tomorrow but I can't figure out what is wrong with this code that it won't output a table to the screen. I don't understand how to embed the html inside of the document.write command. Any help is much appreciated.

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
<head>
<link rel="stylesheet" href="js_styles.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Highest Waterfalls</title>
<script type="text/javascript">
/* <![CDATA[ */
/*
This document prints the names, locations, and heights of the 10 highest waterfalls in the world.
*/
document.write("<h1>Don's Jungle Tours</h1>");
/* ]]> */
</script>
</head>

<body>
<h1>Highest Waterfalls</h1>
<p>The names, locations, and heights of the 10 highest waterfalls in the world are as follows:</p>
<table> <COLGROUP span="3" width="20"/>
<tr><th>Name</th><th>Location</th><th>Height</th></tr>
<script type="text/javascript">
/* <![CDATA[ */
document.write("<tr><th>Name</th><th>Location</th><th>Height (in meters)</th></tr>");
document.write("<tr><td>Angel (upper fall)</td><td>Venezuela</td><td>807</td></tr>";
document.write("<tr><td>Itatinga</td><td>Brazil</td><td>628</td></tr>");
document.write("<tr><td>Cuquenan</td><td>Guyana/Venezuela</td><td>610</td></tr>");
document.write("<tr><td>Ormeli</td><td>Norway</td><td>563</td></tr>");
document.write("<tr><td>Tysse</td><td>Norway</td><td>533</td></tr>");
document.write("<tr><td>Pilao</td><td>Brazil</td><td>524</td></tr>");
document.write("<tr><td>Ribbon</td><td>USA</td><td>491</td></tr>");
document.write("<tr><td>Vestre Mardola</td><td>Norway</td><td>468</td></tr>");
document.write("<tr><td>Kaieteur</td><td>Guyana</td><td>457</td></tr>");
document.write("<tr><td>Cleve-Garth</td><td>New Zealand</td><td>450</td></tr>");
document.write("</table>");
/* ]]> */
</script>
</body>
</html>[/HTML]

Last edited by gits; August 26th, 2008 at 02:54 PM. Reason: added code tags
  #2  
Old August 26th, 2008, 03:03 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: Outputting a Table in javascript


check all your document.write() statements for correct syntax ... have a look at line 25 for example ... ;)

kind regards
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table appearing different in Firefox. jerry101 answers 2 August 5th, 2008 03:58 PM
Problem in Event Handling sorobor answers 2 July 11th, 2007 01:01 PM
Code for returning HTML table data into array? Sugapablo answers 7 July 17th, 2005 03:24 AM