View Full Version : Having trouble creating a table using random rows and column numbers

10-16-2008, 03:10 PM
I'm helping a friend that is interested in writing a script where you generate two random numbers for two variables (one variable will be for the rows and the other will be for the column) in the range from 1 to 10. I want to make sure that each of the cells have the word "cool" in it. It has to have a function where it prints out the table. So far, I have this as my coding:



<table border="2">

var m=Math.round(1 + Math.random()* 10);
var n=Math.round(1 + Math.random()* 10);

for (i=0;i<=m;i++)
function f(n)




I managed to get one column to display but it doesn't seem to expand. Every time I refresh it just changes rows for that one column only.
Anyone have any ideas how I can approach this? Thanks.

10-16-2008, 04:15 PM
Sounds like a homework problem.


You want more than one column, yes? Then code in more than one column. You just have one cell per row in that code.

10-16-2008, 04:17 PM
use DOM
That's valuable for students, as well :)