Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ジャバスクリープツ·テーブル

Name: Anonymous 2011-03-06 19:58

Hey, haven't been to this board before. Anyway, getting into Javascipt... And I'm trying to populate a table with the numbers 1-10, their squares, and cubes. Can someone please help me out?

What I have so far:

<script type="text/javascript">
<!--
   var number = 0;
   var square;
   var cube;
      
   for (var i = 0; i <= 10; i++, number++)
   {
      square = number * number;
      cube = number * number * number;
          
      var table_ref = document.getElementById('num_table');
      var new_row = table_ref.insertRow(-1);
          
      var new_cell = new_row.insertCell(-1);
      var cell_contents = new_cell.innerHTML = number;

      new_cell = new_row.insertCell(-1);
      cell_contents = new_cell.innerHTML = square;
          
      new_cell = new_row.insertCell(-1);
      cell_content = new_cell.innerHTML = cube;
   }
   // -->
</script>

With this in <body>:

<table id="num_table" border="5" width="50%"
   summary="Numbers, Their Squares & Cubes">
   <thead>
      <tr>
         <th>Number</th>
     <th>Square</th>
     <th>Cube</th>
      </tr>
   </thead>
   <tbody>
   </tbody>
</table>

Tried writing the script a few different ways with no luck. Didn't really want to use variables to insert rows/cells but most of the examples I've seen do it, so eh... Thanks in advance!

Name: Anonymous 2011-03-06 20:15

Javascipt
( ≖‿≖)

Name: Anonymous 2011-03-07 4:08

I left my autism bomber at home, enjoy your temporary victory.

Name: Anonymous 2011-03-07 6:05

>>3

fuck you faggot

Name: Anonymous 2013-01-19 23:12

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List