Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-02-2009, 05:37 AM   PM User | #1
Joemoemofo
New Coder

 
Join Date: Jan 2009
Posts: 33
Thanks: 6
Thanked 0 Times in 0 Posts
Joemoemofo is an unknown quantity at this point
NumberOfImagesToRotate Question

Code:
<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?
Joemoemofo is offline   Reply With Quote
Old 01-02-2009, 07:11 AM   PM User | #2
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
Code:
<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>
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Users who have thanked rangana for this post:
Joemoemofo (01-03-2009)
Old 01-03-2009, 04:31 AM   PM User | #3
Joemoemofo
New Coder

 
Join Date: Jan 2009
Posts: 33
Thanks: 6
Thanked 0 Times in 0 Posts
Joemoemofo is an unknown quantity at this point
thanks man! ur the best! been lookin all over!
Joemoemofo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:53 PM.


Advertisement
Log in to turn off these ads.