make it random. |
make it random. |
Feb 13 2006, 11:14 AM
Post
#1
|
|
|
Ill get around to doing that.... ![]() ![]() ![]() ![]() ![]() Group: Member Posts: 518 Joined: Oct 2005 Member No: 275,913 |
Does anyone know how to make a javascript random??????
|
|
|
|
![]() |
| *mipadi* |
Feb 13 2006, 04:58 PM
Post
#2
|
|
Guest |
Try this:
CODE var mem=[];
mem[0]=["Anime feak","http://s15.invisionfree.com/Animeupgrade/index.php?showuser=15"] mem[1]=["Lottery","http://s15.invisionfree.com/Animeupgrade/index.php?showuser=18"] mem[2]=["Raze","http://s15.invisionfree.com/Animeupgrade/index.php?showuser=26"] var displayNumUsers = Math.floor(Math.random() * 3); if (displayNumUsers < 2) { count++; } var count = 0; var users=[]; users[0] = -1; users[1] = -1; users[2] = -1; while (count <= displayNumUsers) { var user; var index; index = Math.floor(Math.random() * mem.length); while (index == users[0] || index == users[1] || index == users[2]) { index = Math.floor(Math.random() * mem.length); } user = mem[index]; var fdiv=document.getElementsByTagName("div") for(a=0;a<fdiv.length;a++) { FakeStaff=''; if(fdiv[a].className=="maintitle" && fdiv[a].innerHTML.match("Board Statistics")) { var UsersOnline=fdiv[parseInt(a)+1] for(c=0;c<mem.length;c++) { UsersOnline.innerHTML+=', <a href="'+user[1]+'">'+user[0]+'</a>' } } } var ftd=document.getElementsByTagName("td") for(a=0;a<ftd.length;a++) { if(ftd[a].className=="pformstrip" && ftd[a].innerHTML.match("active in the past")) { var td=ftd[parseInt(a)+2] var beforeMemNum=td.innerHTML.split("guests, <B>")[0]+"guests, <b>" var afterMemNum='</b> members,'+td.innerHTML.split("</B> members,")[1] var MemNum=parseInt(td.innerHTML.split("guests, <B>")[1].split("</B> members,")[0])+parseInt(mem.length) var nMemCount=beforeMemNum+MemNum+afterMemNum td.innerHTML=nMemCount } } count++; users[count - 1] = index; } |
|
|
|
drilotedahl make it random. Feb 13 2006, 11:14 AM
mipadi Random in what way? JavaScript can generate a rand... Feb 13 2006, 12:09 PM
drilotedahl here Ill post the code...............
<script... Feb 13 2006, 02:59 PM
mipadi Well...I'm still not entirely sure what you... Feb 13 2006, 03:31 PM
drilotedahl ummm. Ok so I akm trying to randomize the differe... Feb 13 2006, 04:26 PM
mipadi Okay. The first thing to do is populate the array,... Feb 13 2006, 04:42 PM
drilotedahl ok I think you may have confused me a bit........
... Feb 13 2006, 04:54 PM
drilotedahl <script>
var mem=[];
mem[0... Feb 13 2006, 05:04 PM
mipadi I think it has something to do with the way the na... Feb 13 2006, 08:03 PM
drilotedahl OK you have me confused. By tweaking do you mean e... Feb 13 2006, 08:44 PM
mipadi Well, the script does something dealing with the T... Feb 13 2006, 09:38 PM
drilotedahl ok then so how would I find out if it is right or ... Feb 13 2006, 09:54 PM
mipadi Output the values of the variables, run a few test... Feb 14 2006, 11:49 AM
drilotedahl Ok I think I hae been through every number combina... Feb 15 2006, 03:47 PM![]() ![]() |