Closed Thread Icon

Preserved Topic: Random Image Generator Question... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18185" title="Pages that link to Preserved Topic: Random Image Generator Question... (Page 1 of 1)" rel="nofollow" >Preserved Topic: Random Image Generator Question... <span class="small">(Page 1 of 1)</span>\

 
YoYoFREAK
Paranoid (IV) Mad Scientist

From: A lost remnant
Insane since: Jun 2001

posted posted 07-19-2001 22:56

I was wondering on how to make an random image generator? I will be developing a members section on my site where they will display a picture of themselves on the home page; To be equal among the players I would like a Random Image Generator. Let's say I have 2 members and the random image generator displays player 2's picture; I would like for them to be able to click on a NEXT PLAYER button so that they can goto player 1's picture, So in effect that button has to know what player is being displayed player 1 or player 2. How would I make the NEXT PLAYER button know which player is being displayed? Sorry if that sounded confusing ,and I don't know wether or not that a random image generator would be perl or Javascript, sorry if I am off topic.
THanks
-YoYoFREAK

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-20-2001 00:33

It could be Perl *or* JavaScript. If you're going to have a large number of members, then I hope you're planning on using Perl, or you'll have to do a lot of updating by hand... not fun.

Either way, you have to use a random number function (Math.random() in JS) to get a number between the first and last images (say, 0 to 3, you would do Math.floor(Math.random()*4) ). Store that number to a variable, and document.write that picture (hopefully it'll be named something like "pic3.jpg" so you can just say "pic" + imagenum + ".jpg"). Then document.write the URL in the link to the next picture in the same way.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-20-2001 02:39


logonames = new Array (
"gurus_logo_ozone2.jpeg",
"gurus_logo_ozone.jpeg",
"gurus_logo_ozone4.gif",
//"guru_ozone6.jpg",
"dl44_green1.jpg",
"dl44_space-portal1.jpg",
"dl44_brownies1.jpg",
"dl44_glass1.jpg",
"dl44_steel1.jpg",
"steve-gurulogo-1.jpg",
"steve-gurulogo-2.jpg",
"steve-gurulogo-3.jpg",
"bugimus_logo1.jpg",
"bugimus_logo2.jpg",
"darkgarden_mash.jpg",
"darkgarden_blade.jpg",
"darkgarden_drip.jpg",
"darkgarden_pill.jpg",
"rend_gurus.jpg",
"rend_gurus2.gif"
);

rando = Math.round( Math.random() * (logonames.length - 1) )

logoname = logonames[rando];

document.write("<IMG ");
document.write("SRC=\"/images/logos/"+logoname+"\" name=\"logo\"");
document.write("WIDTH=\"360\" HEIGHT=\"128\" BORDER=\"0\">");


Stolen straight from gurusnetwork written by Doc


Walking the Earth like Kane

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-20-2001 03:22

This will make the link work (be sure to also include the long list in bitdamaged's post, i didnt want to recopy that:

if (location.search.length == 0)
rando = Math.round( Math.random() * (logonames.length - 1) )
else
rando = location.search.substr(7);

while (rando >= logonames.length) rando -= logonames.length;
while (rando < 0) rando += logonames.length;

logoname = logonames[rando];

document.write('<IMG ');
document.write('SRC="/images/logos/'+logoname+'" name="logo"');
document.write('WIDTH="360" HEIGHT="128" BORDER="0">');

//links:
document.write('<a href="' + window.location + '?rando=' + (rando-1) + '">Previous image</a> ');
document.write('<a href="' + window.location + '?rando=' + (rando+1) + '">Next image</a>');


I didn't actually test that code, it may have an error or two.

[This message has been edited by Slime (edited 07-20-2001).]

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-20-2001 09:25

I have made something like that time ago...It's PHP...hope you can make use of it!

« BackwardsOnwards »

Show Forum Drop Down Menu