View Single Post
Old 05-21-2008, 04:50 AM   #1 (permalink)
sarmenhb
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default stripy table core error

hi i got this piece of code from a book i'm reading called simply javascript by site point and when i execute the javascript i get an error saying that core was not defined. what am i missing?

the code is supposed to stripe a html table.

here is the html table
Code:
<title>Stripy Tables</title>
<style type="text/css">

tr.alt
{
  background-color: #EEEEEE;
}
</style>

<script type="text/javascript" src="stripy_tables.js"></script>

</head>
<body>

<table class="dataTable">
  <thead>
    <tr>
      <th scope="col">
        Web Luminary
      </th>
      <th scope="col">
        Height
      </th>
      <th scope="col">
        Hobbies
      </th>
      <th scope="col">
        Digs microformats?
      </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        John Allsopp
      </td>
      <td class="number">
        6'1"
      </td>
      <td>
        Surf lifesaving, skateboarding, b-boying
      </td>
      <td class="yesno">
        <img src="tick.gif" alt="Yes" />
      </td>
    </tr>    
    </tbody>
  </table>                   
</body>
</html>
and here is the javascript (stripy_tables.js)
Code:
var StripyTables =
{
  init: function()
      {
          var tables = Core.getElementsByClass("dataTable");
var tbodys = tables[i].getElementsByTagName("tbody");
            for ( var i = 0; i < tables.length; i++)
            {
	  var tbodys = tables[i].getElementsByTagName("tbody");
	
	   for (var j = 0; j < tbodys.length; j++)
	     {
                    var rows = tbodys[j].getElementsByTagName("tr");
                      for ( var k = 1; k < rows.length;  k += 2)
	         {  
                        Core.addClass(rows[k], "alt");
	        }
                  }
	   }
	}
};

Core.start(StripyTables);
the error im receiving says

Core is not defined
Core.start(StripyTables);
__________________
no signature set
sarmenhb is offline  
Reply With Quote