Log In · Register

 
make it random.
OneOfTheseDayz
post 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??????
 
 
Start new topic
Replies
*mipadi*
post 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?
 

Posts in this topic


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: