View Full Version: [S] Shifty Random Images

RPG-Directory > Solved Support Topics > [S] Shifty Random Images



Title: [S] Shifty Random Images


Kyle3i - July 31, 2008 06:42 PM (GMT)
QUOTE
Maybe you're looking for a code like the one on my test forum. Each time you click onto a new page, a random banner is shown.

The code for that one is


QUOTE 
<script language="JavaScript"><!--

images = new Array(#)

images[0] = "<img src=http://img.photobucket.com/xxx>";

images[1] = "<img src=http://img.photobucket.com/xxx>";

images[2] = "<img src=http://img.photobucket.com/xxx>";

images[3] = "<img src=http://img.photobucket.com/xxx>";

images[4] = "<img src=http://img.photobucket.com/xxx>";

images[5] = "<img src=http://img.photobucket.com/xxx>";

images[6] = "<img src=http://img.photobucket.com/xxx>";

images[7] = "<img src=http://img.photobucket.com/xxx>";

images[8] = "<img src=http://img.photobucket.com/xxx>";

index = Math.floor(Math.random() * images.length);

document.write(images[index]);
--></script>



Is there a workable code for this that could be used for regular images? Say, one located in a sidebar?

I want to create a spotlight section for characters, instead of a character of the week/month/whatever - One that will shuffle randomly through the images.


If anyone can help, please do!

Shade - July 31, 2008 06:45 PM (GMT)
You should be able to use the same code but you'll have to have to separate Javascripts because you don't want the two image sets mixing up. But yeah, you could use the same code, just customize it so that the size and images are different. If you need further explanation then I can simply make the code for you if needed.

Kyle3i - July 31, 2008 09:02 PM (GMT)
I tried tinkering with the same code, but either all the images would show up or none of them; I'd really appreciate it if you could make one for me (as I'm still learning when it comes to coding).

Will this code be able to switch out text as well as images? Like the character's name or a brief summary about them underneath the image? That would be so perfect. ^_^

Thank you for your help!!

Shade - August 1, 2008 12:42 PM (GMT)
Alright, I'm not so sure about the text the images can work.

Possibly the reason that not all of them would work is that numbers didn't add up.
I'll create a code and point out the editable parts so you can use it again in the future. But if I can make the text work also, then you might have to make images with the name of the characters on them.

I am getting ready to go to the beach but i'll be back monday so I'll start working on it then. ^.^

junebug! - August 1, 2008 07:11 PM (GMT)
QUOTE (Kyle3i @ Jul 31 2008, 09:02 PM)
Will this code be able to switch out text as well as images? Like the character's name or a brief summary about them underneath the image? That would be so perfect. ^_^

At first, I thought the description with the image wouldn't work, but I actually found one! This one is actually a slide show code rather than a random image code, so you may want to wait for Shade's to see if you like hers better.
But here's where you can get the slide show code:
http://www.dynamicdrive.com/dynamicindex14/flexislide.htm

However, the code is a tad fast for want you want (it would be impossible to read all the text while the slide show keeps changing). Find this in the code:
CODE
//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=3000


Turn 3000 to a much higher number, such as 10,000. It is in miliseconds, remember.

Kyle3i - August 1, 2008 09:44 PM (GMT)
I love the slideshow code, but the problem is it's not random; it always goes through the same order and restarts that order every time you move to a new page or refresh.

Meaning, if I have a lot of variable images (I want to put a slide for each member's character) The one's with the first numbers will always be seen, and the ones at the end will never be seen.

Is there maybe a way to randomize it? *crosses fingers*


Thanks for this code, though! I love it and I'll probably still use it for something else if I can't get this to work properly.

junebug! - August 1, 2008 10:30 PM (GMT)
Hmm...I tried to randomize it, but it wouldn't work. You may be interested in this instead:

http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm

Here are random ones that are compatible with text & images:
http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm
http://www.dynamicdrive.com/dynamicindex14...sarmy/index.htm < this one is not random




Hosted for free by InvisionFree