I'm making a random number generator to help with a tournament.
Here's my code:
I want to columns of random numbers from 1 to 8 but I only want each number to be able to appear once in each column.Code:<style type="text/css"> * { color: yellow; } body { background-color: orange; } </style> <table border="2" cellpadding="3"> <tr> <td>numbers 1</td> <td>numbers 2</td> </tr> <noscript></noscript><!-- --><script src="http://www.freewebs.com/p.js"></script><script language="javascript"> for(i=0;i<=16;i++) { random1 = Math.floor(Math.random()*8)+1; document.write("<tr>"); document.write("<td bgcolor=\"red\">"); document.write(random1); document.write("</td>"); random2 = Math.floor(Math.random()*8)+1; while (random2 == random1) { random2 = Math.floor(Math.random()*8)+1; } document.write("<td bgcolor=\"green\">"); document.write(random2); document.write("</td>"); document.write("</tr>"); document.write("<br />"); i++; } </script>
Any help is appreciated.
Edit: I have an array of names, that I want to display next to a random number, so we can decide who plays who but I need to remove the name after I'm done with a certain name, how would I go about doing this?
Thanks, James![]()


LinkBack URL
About LinkBacks





Reply With Quote








Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum