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, 03:31 PM
Post
#2
|
|
Guest |
Well...I'm still not entirely sure what you're trying to make random, but I can make an attempt to parse the code. (JavaScript is not my area of expertise, but the syntax is familiar enough that I am fairly sure I know what's going on.)
CODE var mem=[]; This is declaring an array called mem. The array is empty. CODE mem[mem.length]=["Anime feak","http://s15.invisionfree.com/Animeupgrade/index.php?showuser=15"] mem[mem.length]=["Lottery","http://s15.invisionfree.com/Animeupgrade/index.php?showuser=18"] mem[mem.length]=["Raze","http://s15.invisionfree.com/Animeupgrade/index.php?showuser=26"] This is setting the index of the length of mem to a value--another array, to be exact, making mem a two-dimensional array (as far as I can tell). It seems to be setting the same index to a value...hrm... CODE var fdiv=document.getElementsByTagName("div") This gets an array of all the DIV's in a webpage and stores it in fdiv. CODE 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="'+mem[c][1]+'">'+mem[c][0]+'</a>' } } } This steps through every DIV element on the page. If the DIV is called "maintitle" and it is within an HTML element called "Board Statistics", then the number of users online is stored in the variable usersOnline. Then, the inner for loop steps through every entry in mem and adds on a link with a specified label (from the array mem. CODE var ftd=document.getElementsByTagName("td") Gets an array of every TD element on a page and stores it in the variable ftd. CODE 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 } } This steps through every TD element on the page. If the TD is named "pformstrip" and is within an element specified by "active in the past", then some information is pulled out of ftd and stored in the variable td. The information is then parsed to get some sort of count. Now, what precisely are you trying to randomize? |
|
|
|
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
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
mipadi Try this:
CODEvar mem=[];
mem[0... Feb 13 2006, 04:58 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![]() ![]() |