omega_lonestar

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:

<html>

<head>

</head>

<body>

<table border="2">

<script>

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)

{

document.write(n);

}

}

for(i=0;i<=n;i++)

{

f("<tr><td>Cool</td></tr>");

}

</script>

</body>

</html>

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.

<html>

<head>

</head>

<body>

<table border="2">

<script>

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)

{

document.write(n);

}

}

for(i=0;i<=n;i++)

{

f("<tr><td>Cool</td></tr>");

}

</script>

</body>

</html>

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.