You are here: irt.org | FAQ | JavaScript | Table | Q1463 [ previous next ]
Try:
<body bgcolor="#ffffff"> <style><!-- .cell { position: relative; } //--></style> <script language="JavaScript"><!-- var Cells = 100; function highlight(cell) { var color; for (i=1;i<=Cells;i++) { color = "#ffffff"; if (i%cell==0) color = "#ff0000"; if (document.layers) window.document.layers['cell' + i].bgColor = color; else if (document.all) window.document.all['cell' + i].style.background = color; } } var Text = '<table><tr>'; for (i=1;i<=Cells;i++) { Text += '<td class="cell" id="cell' + i + '"><a href="javascript:;" onClick="highlight(' + i + ')">' + i + '</a></td>'; if (i%10 == 0 && i<Cells) Text += '</tr>\n<tr>'; } Text += '</tr></table>' document.write(Text); //--></script> </body>