Results 1 to 3 of 3
Thread: Random Number and Table
- 02-11-2011, 01:09 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
Random Number and Table
so im just getting started:
I am trying to get a random number generator to generate either a 1,2,3 and then depending on the number put the word "car" into that cell of a table. I then ideally would want the other two empty cells to automatically be filled with a term such as "empty"
this is what i have so far...
<head>
</head>
<body>
<table border="5">
<tr>
<td><script language="Javascript">
<!--
door= new Array
door[1]="car"
door[2]="car"
door[3]="car"
var rand_no = Math.floor((4-1)*Math.random()) + 1;
document.write(door[rand_no]);
-->
</script></td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>door1</td>
<td>door2</td>
<td>door3</td>
</tr>
</table>
<script language="Javascript">
<!--
door= new Array
door[1]="car"
door[2]="car"
door[3]="car"
var rand_no = Math.floor((4-1)*Math.random()) + 1;
document.write(door[rand_no]);
-->
</script>
</body></html>
- 02-11-2011, 01:11 AM #2
This is a Java forum and not a JavaScript forum
- 02-11-2011, 01:12 AM #3
Similar Threads
-
Random Mult. Table
By teelnaw in forum New To JavaReplies: 9Last Post: 10-30-2010, 01:17 AM -
Random number generater
By kickflipper1087 in forum New To JavaReplies: 6Last Post: 10-21-2008, 11:19 PM -
Random number help
By jgonzalez14 in forum New To JavaReplies: 5Last Post: 09-16-2008, 10:13 AM -
Random number
By jithan in forum Advanced JavaReplies: 1Last Post: 06-13-2008, 02:42 PM -
Generate a random number
By romina in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:23 AM
Bookmarks