...

View Full Version : NumberOfImagesToRotate Question



Joemoemofo
01-02-2009, 06:37 AM
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2002 Bontrager Connection, LLC
//
// Type the number of images you are rotating.

NumberOfImagesToRotate = 2;

// Specify the first and last part of the image tag.

FirstPart = '<img src="images/ads/side';
LastPart = '.jpg" height="151" width="222">';

function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write(FirstPart + r + LastPart);
}
//-->
</script>

Okay, I have this to rotate advertisement images for me. However, I want to add a seperate URL to each image that I have. How would I go about doing that?

rangana
01-02-2009, 08:11 AM
<script type="text/javascript">
/**
* Copyright 2002 Bontrager Connection, LLC
* Modified @ codingforums.com by rangana on this thread: http://codingforums.com/showthread.php?t=155309
* Ability to add a separate URL to each image
*/

// Initialize the links you like to use - should match on the NumberOfImagesToRotate var
links=['http://www.link1.com','http://www.link2.com'];

// Type the number of images you are rotating.
NumberOfImagesToRotate = 2;

// Specify the first and last part of the image tag.
FirstPart = '<img src="images/ads/side';
LastPart = '.jpg" height="151" width="222">';

function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write('<a href="'+links[r-1]+'">' + FirstPart + r + LastPart + '</a>');
}
</script>

Joemoemofo
01-03-2009, 05:31 AM
thanks man! ur the best! been lookin all over!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum