Reply
How to Use this Image Reload Script Twice?
Old 03-25-2008, 02:22 PM How to Use this Image Reload Script Twice?
Experienced Talker

Posts: 39
I have a great image reload script; problem is I want to use it to change two separate images on the same page.

It calls "xoxo", I think if I can change this to say something else it may work; but problem is xoxo may be something special? not sure.

Any Ideas?

This code goes in place of the image:

Code:
<SCRIPT language=JavaScript> document.writeln('<TD'+'><IMG SRC="'+xoxo[choice]+'"><'+'/TD>');</SCRIPT>

Here is header code:

Code:
   var ic = 4;     

var xoxo = new Array(ic); 

xoxo[0] = "images/banner2.jpg";
xoxo[1] = "images/banner3.jpg";
xoxo[2] = "images/banner4.jpg";
xoxo[3] = "images/banner5.jpg";

function pickRandom(range) {

if (Math.random)

return Math.round(Math.random() * (range-1));

else {

var now = new Date();

return (now.getTime() / 1000) % range;

}

}

// Write out an IMG tag, using a randomly-chosen image name.

var choice = pickRandom(ic);
Boar is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 03-25-2008, 03:48 PM Re: How to Use this Image Reload Script Twice?
chrishirst's Avatar
Super Moderator

Posts: 10,639
Location: Blackpool. UK
xoxo is the array of image names

to have two random images

just call the randomiser twice

var img1 = pickRandom(ic);
var img2 = pickRandom(ic);

then show the image

SRC="'+xoxo[img1]+'"
SRC="'+xoxo[img2]+'"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-27-2008, 09:20 AM Re: How to Use this Image Reload Script Twice?
Junior Talker

Posts: 2
This is ust what i need thanks for posting! :]
bioanimal is offline
Reply With Quote
View Public Profile
 
Old 05-08-2008, 09:26 AM Re: How to Use this Image Reload Script Twice?
Experienced Talker

Posts: 39
Quote:
Originally Posted by chrishirst View Post
xoxo is the array of image names

to have two random images

just call the randomiser twice

var img1 = pickRandom(ic);
var img2 = pickRandom(ic);

then show the image

SRC="'+xoxo[img1]+'"
SRC="'+xoxo[img2]+'"
Chris, thanks for the help, but I still don't quite understand.

If I replace the very last line of code with this:

var img1 = pickRandom(ic);
var img2 = pickRandom(ic);

then all of the images are still named x0x0, so it would be confused?

What I need to do is call two separate sets of images, one for each call.

Could you maybe add this code into the main file, so I can see how this would work?
Boar is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to How to Use this Image Reload Script Twice?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.14789 seconds with 14 queries