Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 78
Trades: 0
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
 
 
Register now for full access!
Old 03-25-2008, 04:48 PM Re: How to Use this Image Reload Script Twice?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-27-2008, 10:20 AM Re: How to Use this Image Reload Script Twice?
Junior Talker

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

Posts: 78
Trades: 0
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
 
Reply     « Reply to How to Use this Image Reload Script Twice?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.90510 seconds with 12 queries