Connecting Tech Pros Worldwide Help | Site Map

Outputting a Table in javascript

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 26th, 2008, 01:25 PM
Newbie
 
Join Date: Aug 2008
Location: Champaign
Age: 23
Posts: 2
Default Outputting a Table in javascript

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 01:54 PM. Reason: added code tags
Reply
  #2  
Old August 26th, 2008, 02:03 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 37
Posts: 3,780
Default

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

kind regards
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.