Logo  

CS479/579 - Web Programming II

Displaying ./code/ES/table1.html

<!-- A comment -->
<!DOCTYPE html>
<html>
<head>
 <title> Table by document write </title>
 <meta charset='utf-8'>
<!--
 <link rel='stylesheet' src='styles.css' type='text/css' />
-->
 <style>
 </style>
 <script>
 </script>
</head>
<body>
<table border=1>
<tbody>
<script>
 /**
  * Creates a 20x20 table as the document loads.  Note that attempting to use
  * document.write() _after_ the page has finished loading will force a call
  * document.open() which will erase the current document.  Also note how
  * script sections like this are processed as the page loads, much like how
  * a PHP script is processed.
  */
 var rows = 20, cols = 20;
 for(var r = 0; r < rows; r++) {
   document.write("<tr>");
   for(var c = 0; c < cols; c++) {
     // Works much the same as console.log.  Note that we probably should
     // close tags, (even if we don't need to because of HTML 5,) because
     // the JS engine will often complain that we aren't.
     document.write("<td>", r, ",", c, "</td>");
   }
   document.write("</tr>");
 }
</script>
</tbody>
</table>
</body>
</html>