This code pasted below is used for one set of four images rotating randomly.What part of the code do I change to have three sets of four images rotating at random next to each other?
code:
<!– THREE STEPS TO INSTALL RANDOM IMAGE ROTATOR:
1. Copy the coding into the HEAD of your HTML document2. Add the onLoad event handler into the BODY tag3. Put the last coding into the BODY of your HTML document –>
<!– STEP ONE: Paste this code into the HEAD of your HTML document –>
[code]
<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Original: Robert Bui ([email protected]) –>
<!– Web Site: [url]http://astrogate.virtualave.net[/url] –>
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>
<!– Begin
var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;
var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/01.jpg”);
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/02.jpg”);
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/03.jpg”);
image_list[image_index++] = new imageItem(“http://javascript.internet.com/img/image-cycler/04.jpg”);
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y – x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = “rotateImage(‘”+place+”‘)”;
setTimeout(recur_call, interval);
}
// End –>
</script>
</HEAD>
<!– STEP TWO: Insert the onLoad event handler into your BODY tag –>
<BODY OnLoad=”rotateImage(‘rImage’)”>
<!– STEP THREE: Copy this code into the BODY of your HTML document –>
<center>
<img name=”rImage” src=”http://javascript.internet.com/img/image-cycler/01.jpg” width=120 height=90>
</center>
<p><center>
<font face=”arial, helvetica” size=”-2″>Free JavaScripts provided<br>
by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
</center><p>
<!– Script Size: 2.29 KB –>
<i>
</i><html>
<HEAD>
<title>Rotating Banners</title>
<!--
Original: Robert Bui ([email protected])
Web Site: http://astrogate.virtualave.net
Extensively modified by Jay Rumsey
From: http://www.webdeveloper.com/forum/showthread.php?t=201788
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
-->
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
var interval = 2.5; // delay between rotating images (in seconds)
interval *= 1000;
var random_display = 1; // 0 = no, 1 = yes
var image_index = 0;
image_list = [ // 3 groups of 4 images --- Keep symetrical
["http://javascript.internet.com/img/image-cycler/01.jpg"],
["http://javascript.internet.com/img/image-cycler/02.jpg"],
["http://javascript.internet.com/img/image-cycler/03.jpg"],
["http://javascript.internet.com/img/image-cycler/04.jpg"],
["http://javascript.internet.com/img/image-cycler/02.jpg"],
["http://javascript.internet.com/img/image-cycler/03.jpg"],
["http://javascript.internet.com/img/image-cycler/04.jpg"],
["http://javascript.internet.com/img/image-cycler/01.jpg"],
["http://javascript.internet.com/img/image-cycler/03.jpg"],
["http://javascript.internet.com/img/image-cycler/04.jpg"],
["http://javascript.internet.com/img/image-cycler/01.jpg"],
["http://javascript.internet.com/img/image-cycler/02.jpg"] // Note: no comma after last entry
];
var number_of_image = image_list.length / 3; // array size / number of groups (3 for this example)
function generate(range) {
return Math.floor(Math.random() * range);
}
function getNextImage() {
if (random_display) {
image_index = generate(number_of_image); // 0..number of images in group
} else {
image_index = (image_index+1) % number_of_image;
}
return image_index;
}
function rotateImage(place) {
place = getNextImage();
document.getElementById('Limage').src = image_list[place];
document.getElementById('Mimage').src = image_list[place+4]; // number of items in group (4 for this)
document.getElementById('Rimage').src = image_list[place+8];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
</script>
</HEAD>
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<BODY OnLoad="rotateImage(0)">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<center>
<img name="lImage" id='Limage'
src="http://javascript.internet.com/img/image-cycler/01.jpg" width=120 height=90>
<img name="mImage" id='Mimage'
src="http://javascript.internet.com/img/image-cycler/02.jpg" width=120 height=90>
<img name="rImage" id='Rimage'
src="http://javascript.internet.com/img/image-cycler/03.jpg" width=120 height=90>
</center>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
</body>
</html>
What part of the code do I change to have three sets of four images rotating at random next to each other?I thought I fulfilled.
[/QUOTE]
I'm not sure what you are trying to accomplish.
You only provided 4 pictures. I just copied the same group of 4, but it should be fairly easy to change or add to the image list.
Your original request I thought I fulfilled.
What is it that you want to do differently. ?[/QUOTE]
Ummm if that was directed at my response directly above yours, I was not the OP, I was just asking a general question about your solution.
To clarify my question, if you have 4 pictures (as in the OP's code), and you want to display 3 at once randomly, using your code suggestion, will it:
A. always produce 3 different pictures at once (i.e. #4,#1,#3 or #3,#2,#1)
or
B. will it be completely random so you may get repeats of the same pic at the same time (i.e. #4,#2,#4 or #2,#2,#1 or even #3,#3,#3)
Just wondering because recently I had a similar project and used a different solution.[/QUOTE]
<i>
</i>image_list = [ // 1 group of 4 images
["http://javascript.internet.com/img/image-cycler/01.jpg"],
["http://javascript.internet.com/img/image-cycler/02.jpg"],
["http://javascript.internet.com/img/image-cycler/03.jpg"],
["http://javascript.internet.com/img/image-cycler/04.jpg"]
];
...
var number_of_image = image_list.length; // 1; // array size/number of groups
...
function rotateImage(place) {
place = getNextImage();
document.getElementById('Limage').src = image_list[place];
document.getElementById('Mimage').src = image_list[place+1]; // number of items in group (4 for this)
document.getElementById('Rimage').src = image_list[place+2];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
<i>
</i>function rotateImage(place) {
place = getNextImage();
document.getElementById('Limage').src = image_list[place];
place = getNextImage();
document.getElementById('Mimage').src = image_list[place]; // number of items in group (4 for this)
place = getNextImage();
document.getElementById('Rimage').src = image_list[place];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
[CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
imagelist = [];
imagelist[0] ="http://javascript.internet.com/img/image-cycler/02.jpg";
imagelist[1] ="http://javascript.internet.com/img/image-cycler/03.jpg";
imagelist[2] ="http://javascript.internet.com/img/image-cycler/04.jpg";
function Rotate(id,ary,spd,srt){
var obj=document.getElementById(id);
var roop=new RotateOOP(obj,ary,spd,srt);
}
function RotateOOP(obj,ary,spd,srt){
this.obj=obj;
this.ary=ary;
this.ary=ary.concat(obj.src);
this.spd=spd||2000;
this.cnt=srt||0;
this.to=null;
this.srcary=[];
this.to=setTimeout(function(oop){return function(){oop.rotate();}}(this),this.spd);
}
RotateOOP.prototype.rotate=function(){
if (!this.srcary[this.cnt]){
this.srcary[this.cnt]=new Image();
this.srcary[this.cnt].src=this.ary[this.cnt];
}
if (!this.srcary[this.cnt].complete){
return this.to=setTimeout(function(){ this.rotate(); },500);
}
this.obj.src=this.srcary[this.cnt].src;
this.cnt=++this.cnt%this.ary.length;
this.to=setTimeout(function(oop){return function(){oop.rotate();}}(this),this.spd);
}
/*]]>*/
</script>
</head>
<body onload="Rotate('tst1',imagelist,2000,0);Rotate('tst2',imagelist,3000,0);Rotate('tst3',imagelist,1000,0);">
<img id="tst1" src="http://javascript.internet.com/img/image-cycler/01.jpg" />
<img id="tst2" src="http://javascript.internet.com/img/image-cycler/01.jpg" />
<img id="tst3" src="http://javascript.internet.com/img/image-cycler/01.jpg" />
</form>
</body>
</html>[/CODE]
[CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
imagelist = [];
imagelist[0] ="http://javascript.internet.com/img/image-cycler/02.jpg";
imagelist[1] ="http://javascript.internet.com/img/image-cycler/03.jpg";
imagelist[2] ="http://javascript.internet.com/img/image-cycler/04.jpg";
function Rotate(id,ary,spd,srt){
var obj=document.getElementById(id);
var roop=new RotateOOP(obj,ary,spd,srt);
}
function RotateOOP(obj,ary,spd,srt){
this.obj=obj;
this.ary=ary;
this.ary=ary.concat(obj.src);
this.spd=spd||2000;
this.cnt=srt||0;
this.to=null;
this.srcary=[];
this.to=setTimeout(function(oop){return function(){oop.rotate();}}(this),this.spd);
}
RotateOOP.prototype.rotate=function(){
clearTimeout(this.to);
if (!this.srcary[this.cnt]){
this.srcary[this.cnt]=new Image();
this.srcary[this.cnt].src=this.ary[this.cnt];
}
if (!this.srcary[this.cnt].complete){
return this.to=setTimeout(function(oop){return function(){oop.rotate();}}(this),500);
}
this.obj.src=this.srcary[this.cnt].src;
this.cnt=++this.cnt%this.ary.length;
this.to=setTimeout(function(oop){return function(){oop.rotate();}}(this),this.spd);
}
/*]]>*/
</script>
</head>
<body onload="Rotate('tst1',imagelist,2000,0);Rotate('tst2',imagelist,3000,0);Rotate('tst3',imagelist,1000,0);">
<img id="tst1" src="http://javascript.internet.com/img/image-cycler/01.jpg" />
<img id="tst2" src="http://javascript.internet.com/img/image-cycler/01.jpg" />
<img id="tst3" src="http://javascript.internet.com/img/image-cycler/01.jpg" />
</form>
</body>
</html>[/CODE]
<i>
</i><body onload="FP_preloadImgs(/*url*/'button7B.gif', /*url*/'button7C.gif', /*url*/'button84.gif', /*url*/'button85.gif', /*url*/'button8D.gif', /*url*/'button8E.gif', /*url*/'button90.gif', /*url*/'button91.gif', /*url*/'button93.gif', /*url*/'button94.gif', /*url*/'button96.gif', /*url*/'button97.gif', /*url*/'button33.gif', /*url*/'button32.gif', /*url*/'button2A1.gif', /*url*/'button30.gif', /*url*/'button42.gif', /*url*/'button35.gif', /*url*/'button3F1.gif', /*url*/'button3E1.gif', /*url*/'button43.gif', /*url*/'button44.gif', /*url*/'button45.gif', /*url*/'button46.gif')" style="background-color: #00FF00; background-image: url('')">
.....
.....
.....
</body>
<BODY OnLoad="rotateImage(0)">
<i>
</i>image_list = [ // 2 groups of 4 images --- Keep symetrical
["flower1left.jpg"],
["flower2left.jpg"],
["flower3left.jpg"],
["flower4left.jpg"],
["flower2left.jpg"],
["flower3left.jpg"],
["flower4left.jpg"],
["flower1left.jpg"] // Note: no comma after last entry
];
var number_of_image = image_list.length / 2; // array size / number of groups (3 for this example)
.....
function rotateImage(place) {
place = getNextImage();
document.getElementById('Limage').src = image_list[place];
document.getElementById('Mimage').src = image_list[place+4]; // number of items in group (4 for this)
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
.....
<tr>
<td align="left" id="toptd" style="background-color: #008000; background-image:url('top-bg2.jpg')">
<img border="0" src="barleft.jpg" width="34" height="180">
<img name="lImage" id='Limage' src="flower1left.jpg" width="160" height="179">
<img border="0" src="barmiddle.jpg" width="30" height="180">
<img name="mImage" id='Mimage'
src="flower2left.jpg" width="160" height="179">
<img border="0" src="barmiddle.jpg" width="12" height="180">
<img name="rImage" id='Rimage' src="barright.jpg" width="341" height="180">
</td>
</tr>
<i>
</i><!-- DOC statement of your choice -->
<html>
<head>
<title>Title of Program</title>
<!-- two methods follow to add scripts to HTML document -->
<script type="text/javascript" src="external.js"></script>
<script type="text/javascript">
// internal script contents
</script>
</head>
<body> <!-- include onload="function()" if appropriate here -->
<!-- Program with JS calls or additional <script> tag contents -->
</body>
</html>
Is it possible for the administrator or person with the authority - to remove this thread? Regards, 08hirobinj.[/QUOTE]
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
var interval = 2.5; // delay between rotating images (in seconds)
interval *= 1000;
var random_display = 1; // 0 = no, 1 = yes
var image_index = 0;
image_list = [ // 2 groups of 5 images --- Keep symetrical
["images/splash-left-01.jpg"],
["images/splash-left-02.jpg"],
["images/splash-left-03.jpg"],
["images/splash-left-04.jpg"],
["images/splash-left-05.jpg"],
["images/splash-right-05.jpg"],
["images/splash-right-02.jpg"],
["images/splash-right-03.jpg"],
["images/splash-right-04.jpg"],
["images/splash-right-01.jpg"] // Note: no comma after last entry
];
var number_of_image = image_list.length / 2; // array size / number of groups (3 for this example)
function generate(range) {
return Math.floor(Math.random() * range);
}
function getNextImage() {
if (random_display) {
image_index = generate(number_of_image); // 0..number of images in group
} else {
image_index = (image_index+1) % number_of_image;
}
return image_index;
}
function rotateImage(place) {
place = getNextImage();
document.getElementById('Limage').src = image_list[place];
document.getElementById('Rimage').src = image_list[place+5]; // number of items in group (4 for this)
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
</script>
[/QUOTE]
<i>
</i><html>
<head>
<title>Multiple Timed Galleries</title>
<script type="text/javascript">
// For: http://www.webdeveloper.com/forum/showthread.php?t=201788&page=2
var Fortunato = [
['http://www.westsierrahanoverians.com/images/fortunato_foal2.jpg','3 days old'],
['http://www.westsierrahanoverians.com/images/fortunato_foal.jpg','3 monhs old'],
['http://www.westsierrahanoverians.com/images/fortunato_canter.jpg','Canter'],
['http://www.westsierrahanoverians.com/images/forunato_trot.jpg','Trot'] // Note: NO comma after last entry
];
var Mares = [
['http://www.westsierrahanoverians.com/images/wakanova_conf.jpg','Wakanova'],
['http://www.westsierrahanoverians.com/images/princess_canter.jpg','Princess'],
['http://www.westsierrahanoverians.com/images/dona_fran_trot.jpg','Dona Fran trot'],
['http://www.westsierrahanoverians.com/images/wakanova_trot2.jpg','Wakanova trot']
];
function SetImage(IDS,imgPtr) {
var ImageList = new Array();
if (IDS == 'BigFortunato') { ImageList = Fortunato; }
if (IDS == 'BigMares') { ImageList = Mares; }
document.getElementById(IDS).src=ImageList[imgPtr][0];
document.getElementById(IDS).alt=ImageList[imgPtr][0];
document.getElementById(IDS+'Caption').innerHTML = ImageList[imgPtr][1];
// for testing purposes only
// document.getElementById('test').innerHTML = IDS+':'+imgPtr+'<br>r1 '+rImage1Cnt+':'+rImage1+"<br>r2 "+rImage2Cnt+':'+rImage2;
}
var ImageSet;
var rImage1 = 0; var rImage1Cnt = 0;
var rImage2 = 0; var rImage2Cnt = 0;
function NextImage() {
rImage1Cnt++;
if (rImage1Cnt % 3 == 0) {
/* For sequential image displays */ rImage1 = ((rImage1+1) % Fortunato.length);
/* For randomized image displays */ // rImage1 = Math.floor(Math.random()*Fortunato.length);
SetImage('BigFortunato',rImage1);
}
rImage2Cnt++; <br/>
if (rImage2Cnt % 4 == 0) {
/* For sequential image displays */ rImage2 = ((rImage2+1) % Mares.length);
/* For randomized image displays */ // rImage2 = Math.floor(Math.random()*Mares.length);
SetImage('BigMares',rImage2);
}
}
function SetupTimers() { ImageSet = setInterval("NextImage()",1000); }
function StopChanges() { clearTimeout(ImageSet); }
</script>
</head>
<body onload="SetupTimers()">
<table border="1" align="center"><tr>
<td> <img id="BigMares"
src='http://www.westsierrahanoverians.com/images/wakanova_conf.jpg'
alt='http://www.westsierrahanoverians.com/images/wakanova_conf.jpg'
<i> ></i>
<br><span id="BigMaresCaption">Mares Caption</span>
</td>
<td width="10%">&nbsp;</td>
<td> <img id="BigFortunato"
src='http://www.westsierrahanoverians.com/images/fortunato_foal2.jpg'
alt='http://www.westsierrahanoverians.com/images/fortunato_foal2.jpg'
<i> ></i>
<br><span id="BigFortunatoCaption">Fortunato Caption</span>
</td>
</tr></table>
<button onclick="StopChanges()">Stop Changes</button>
<div id="test"></div>
</body>
</html>
Thanks for the help ? I think that would do the trick! I truly appreciate it.[/QUOTE]
this helped me greatly!
brilliant, thanks, also thanks for the clear comments, helped me change the amount of pictures without trouble![/QUOTE]
This is great. I'm working with the "Multiple Timed Galleries", is there anyway to have non-symetrical arrays? I have a need to display multiple galleries, but different amount of images...
Thanks for any help![/QUOTE]
<i>
</i>document.getElementById('2image').src = image_list[place];
document.getElementById('3image').src = image_list[place+4];
document.getElementById('4image').src = image_list[place+8];
document.getElementById('5image').src = image_list[place+14];
document.getElementById('6image').src = image_list[place+16];
document.getElementById('6image').src = image_list[place+20];
document.getElementById('6image').src = image_list[place+24];
document.getElementById('6image').src = image_list[place+28];
[CODE]<html>
<HEAD>
<title>Rotating Banners</title>
<!--
Modified based on script by Jay Rumsey
From: http://www.webdeveloper.com/forum/showthread.php?t=201788
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
-->
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
var interval = 5; // delay between rotating images (in seconds)
interval *= 1000;
var random_display = 0; // 0 = no, 1 = yes
var image_index = 0;
image_list = [ // 3 groups of 4 images --- Keep symetrical
["http://www.clan-dragon.org/images/4.jpg"],
["http://www.clan-dragon.org/images/1.jpg"],
["http://www.clan-dragon.org/images/2.jpg"],
["http://www.clan-dragon.org/images/3.jpg"],
["http://www.clan-dragon.org/images/b1.jpg"],
["http://www.clan-dragon.org/images/b2.jpg"],
["http://www.clan-dragon.org/images/b3.jpg"],
["http://www.clan-dragon.org/images/b4.jpg"],
["http://www.clan-dragon.org/images/b2.jpg"],
["http://www.clan-dragon.org/images/b3.jpg"],
["http://www.clan-dragon.org/images/b4.jpg"],
["http://www.clan-dragon.org/images/b1.jpg"],
["http://www.clan-dragon.org/images/b3.jpg"],
["http://www.clan-dragon.org/images/b4.jpg"],
["http://www.clan-dragon.org/images/b1.jpg"],
["http://www.clan-dragon.org/images/b2.jpg"] // Note: no comma after last entry
];
var number_of_image = image_list.length / 4; // array size / number of groups (3 for this example)
function generate(range) {
return Math.floor(Math.random() * range);
}
function getNextImage() {
if (random_display) {
image_index = generate(number_of_image); // 0..number of images in group
} else {
image_index = (image_index+1) % number_of_image;
}
return image_index;
}
function rotateImage(place) {
place = getNextImage();
document.getElementById('Timage').src = image_list[place];
document.getElementById('Limage').src = image_list[place+4];
document.getElementById('Mimage').src = image_list[place+8]; // number of items in group (4 for this)
document.getElementById('Rimage').src = image_list[place+12];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
</script>
</HEAD>
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<BODY OnLoad="rotateImage(0)">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<center>
<img name="tImage" id='Timage'
src="http://www.clan-dragon.org/images/1.jpg" width=527 height=213><br>
<img name="lImage" id='Limage'
src="http://www.clan-dragon.org/images/b2.jpg" width=165 height=245>
<img name="mImage" id='Mimage'
src="http://www.clan-dragon.org/images/b3.jpg" width=165 height=245>
<img name="rImage" id='Rimage'
src="http://www.clan-dragon.org/images/b4.jpg" width=165 height=245>
</center>
<p><center>
</center><p>
</body>
</html>[/CODE]
I know this is a necro post, but the information is by far the best I've found for doing multiple banners on one page. I've run into 2 minor issues for my site...so if anyone has any suggestions.
1) I can't seem to add href that rotates with the images without disabling the rotation...and I know it has to be something simple I'm missing
2) The other odd issue I'm running into is that the script is working fine in IE but doesnt seem to in FF or Chrome. I've even looked over to see if the script is just that out of date (hey it is from a necro post after all) and everthing seems to be in order.
Answer to these questions would be much appriciated. Here is what I've tweaked the script into so far:
...
[/QUOTE]
Well I rechecked my FF. Seems my java was out of date so it stopping the local run of the code from rotating. Now that I got that working I entered it into the main site line by line and it works in a preview local version. Soon as I upload it to my host though the code stops rotating. I have other java codes on the same page so I made sure to check it for any over lapping code and cant find any. The site iswww.clan-dragon.org...I cant post the full code here cause it is too long...any clues would be very helpful[/QUOTE]
Eureka..I found the issue. Seems there was a piece of code burried for pop up on one of the title sections. So at least 1 issue is down...any hints on how to get the HREF to work properly?[/QUOTE]
<i>
</i><script language="javascript">
<!--
Today = new Date();
TodayDay = Today.getDate();
TodayMon = Today.getMonth();
TodayYear = Today.getYear();
if (TodayMon == 0) { TodayMonth = "January"; }
else if (TodayMon == 1) { TodayMonth = "February"; }
else if (TodayMon == 2) { TodayMonth = "March"; }
else if (TodayMon == 3) { TodayMonth = "April"; }
else if (TodayMon == 4) { TodayMonth = "May"; }
else if (TodayMon == 5) { TodayMonth = "June"; }
else if (TodayMon == 6) { TodayMonth = "July"; }
else if (TodayMon == 7) { TodayMonth = "August"; }
else if (TodayMon == 8) { TodayMonth = "September"; }
else if (TodayMon == 9) { TodayMonth = "October"; }
else if (TodayMon == 10) { TodayMonth = "November"; }
else if (TodayMon == 11) { TodayMonth = "December"; }
else { TodayMonth = TodayMon; }
document.write(TodayMonth + " " + TodayDay + ", " + TodayYear);
-->
</script>
<i>
</i><script type="text/javascript">
var Today = new Date();
var Months = ['January','February','March','April','May','June',
'July','August','September','October','November','December'];
document.write(Months[Today.getMonth()] + " " + Today.getDate() + ", " + Today.getYear());
</script>
[CODE]<html>
<HEAD>
<title>Clan-Dragon.org Rotating Banners</title>
<!--
Modified based on script by Jay Rumsey
From: http://www.webdeveloper.com/forum/showthread.php?t=201788
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
-->
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
var interval = 5000;
var random_display = 0; // 0 = no, 1 = yes
var image_index = 0;
image_list = [ // 3 groups of 4 images --- Keep symetrical
["http://www.clan-dragon.org/images/4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"],
["http://www.clan-dragon.org/images/3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/b2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"],
["http://www.clan-dragon.org/images/b3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/b2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"],
["http://www.clan-dragon.org/images/b3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/b1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/b3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/b1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/b2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"] // Note: no comma after last entry
];
var number_of_image = image_list.length / 4; // array size / number of groups (3 for this example)
function generate(range) {
return Math.floor(Math.random() * range);
}
function getNextImage() {
if (random_display) {
image_index = generate(number_of_image); // 0..number of images in group
} else {
image_index = (image_index+1) % number_of_image;
}
return image_index;
}
function rotateImage(place) {
place = getNextImage();
document.getElementById('Timage').src = image_list[place][0];
document.getElementById('Limage').src = image_list[place+4][0];
document.getElementById('Mimage').src = image_list[place+8][0]; document.getElementById('Rimage').src = image_list[place+12][0]; // number of items in group (4 for this)
document.getElementById('TLink').src = image_list[0][1];
document.getElementById('LLink').src = image_list[0][1+4];
document.getElementById('MLink').src = image_list[0][1+8]; document.getElementById('RLink').src = image_list[0][1+12];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
</script>
</HEAD>
<BODY OnLoad="rotateImage(0)">
<center>
<a id='TLink' target="_top">
<img name="tImage" id='Timage'
src="http://www.clan-dragon.org/images/1.jpg" width=527 height=213><br></a>
<a href="" id="LLink" target="_top">
<img name="lImage" id='Limage'
src="http://www.clan-dragon.org/images/b2.jpg" width=165 height=245></a>
<a href="" id="MLink" target="_top">
<img name="mImage" id='Mimage'
src="http://www.clan-dragon.org/images/b3.jpg" width=165 height=245></a>
<a href="" id="RLink" target="_top">
<img name="rImage" id='Rimage'
src="http://www.clan-dragon.org/images/b4.jpg" width=165 height=245></a>
</center>
<p><center>
</center><p>
</body>
</html>[/CODE]
<i>
</i>function rotateImage(place) {
place = getNextImage();
document.getElementById('Timage').src = image_list[place][0];
document.getElementById('Limage').src = image_list[place+4][0];
document.getElementById('Mimage').src = image_list[place+8][0]; document.getElementById('Rimage').src = image_list[place+12][0]; // number of items in group (4 for this)
document.getElementById('TLink').src = image_list[0][1];
document.getElementById('LLink').src = image_list[0][1+4];
document.getElementById('MLink').src = image_list[0][1+8]; document.getElementById('RLink').src = image_list[0][1+12];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
<i>
</i>function rotateImage(place) {
place = getNextImage();
document.getElementById('Timage').src = image_list[place][0];
document.getElementById('Limage').src = image_list[place+4][0];
document.getElementById('Mimage').src = image_list[place+8][0]; <br/>
document.getElementById('Rimage').src = image_list[place+12][0]; // number of items in group (4 for this)
document.getElementById('TLink').src = image_list[place][1];
document.getElementById('LLink').src = image_list[place+4][1];
document.getElementById('MLink').src = image_list[place+8][1]; <br/>
document.getElementById('RLink').src = image_list[place+12][1];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
<html>
<HEAD>
<title>Clan-Dragon.org Rotating Banners</title>
<!--
Modified based on script by Jay Rumsey
From: http://www.webdeveloper.com/forum/showthread.php?t=201788
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
-->
<SCRIPT type="text/javascript">
var interval = 5000;
var random_display = 0; // 0 = no, 1 = yes
var image_index = 0;
image_list = [ // 3 groups of 4 images --- Keep symetrical
["http://www.clan-dragon.org/images/4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"],
["http://www.clan-dragon.org/images/3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/b2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"],
["http://www.clan-dragon.org/images/b3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/b2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"],
["http://www.clan-dragon.org/images/b3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/b1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/b3.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=20"],
["http://www.clan-dragon.org/images/b4.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=19"],
["http://www.clan-dragon.org/images/b1.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=9"],
["http://www.clan-dragon.org/images/b2.jpg","http://www.clan-dragon.org/forum/forumdisplay.php?fid=14"] // Note: no comma after last entry
];
var number_of_image = image_list.length / 4; // array size / number of groups (3 for this example)
function generate(range) {
return Math.floor(Math.random() * range);
}
function getNextImage() {
if (random_display) {
image_index = generate(number_of_image); // 0..number of images in group
} else {
image_index = (image_index+1) % number_of_image;
}
return image_index;
}
function rotateImage(place) {
place = getNextImage();
document.getElementById('Timage').src = image_list[place][0];
document.getElementById('Limage').src = image_list[place+4][0];
document.getElementById('Mimage').src = image_list[place+8][0]; <br/>
document.getElementById('Rimage').src = image_list[place+12][0];
document.getElementById('TLink').href = image_list[place][1];
document.getElementById('LLink').href = image_list[place+4][1];
document.getElementById('MLink').href = image_list[place+8][1];
document.getElementById('RLink').href = image_list[place+12][1];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY OnLoad="rotateImage(0)">
<center>
<a name="TLink" id="TLink" href="http://www.clan-dragon.org/forum/forumdisplay.php?fid=9" target="_top">
<img src="http://www.clan-dragon.org/images/1.jpg" name="tImage" width=527 height=213 id='Timage'></a><br>
<i> </i><a name="LLink" id="LLink" href="http://www.clan-dragon.org/forum/forumdisplay.php?fid=14" target="_top">
<img name="lImage" id='Limage'
src="http://www.clan-dragon.org/images/b2.jpg" width=165 height=245></a>
<i> </i><a name="MLink" href="http://www.clan-dragon.org/forum/forumdisplay.php?fid=20" id="MLink" target="_top">
<img name="mImage" id='Mimage'
src="http://www.clan-dragon.org/images/b3.jpg" width=165 height=245></a>
<i> </i><a name="Link" href="http://www.clan-dragon.org/forum/forumdisplay.php?fid=19" id="RLink" target="_top">
<img name="rImage" id='Rimage'
src="http://www.clan-dragon.org/images/b4.jpg" width=165 height=245></a>
</center>
<p><center>
</center><p>
</body>
</html>
well first I took your change to set the "reference" area be in the correct area. Then it dawned on me that I needed it to look for an HREF reference not an SRC reference. So I changed it from:
document.getElementById('TLink').[B]src[/B] = image_list
to
document.getElementById('TLink').[B]HREF[/B] = image_list
Then just to make sure I made a duplicate of the src line so it would have a name on the line, an id, and the correct Href to start the rotation with. I am kinda curious about how much more difficult it would be to add an ALT tag that rotates with the image as well...hmmm Let me know if you have any ideas on that one[/QUOTE]
<i>
</i>function rotateImage(place) {
place = getNextImage();
document.getElementById('Timage').src = image_list[place][0];
document.getElementById('Limage').src = image_list[place+4][0];
document.getElementById('Mimage').src = image_list[place+8][0]; <br/>
document.getElementById('Rimage').src = image_list[place+12][0];
document.getElementById('Timage').alt = image_list[place][0];
document.getElementById('Limage').alt = image_list[place+4][0];
document.getElementById('Mimage').alt = image_list[place+8][0]; <br/>
document.getElementById('Rimage').alt = image_list[place+12][0];
document.getElementById('TLink').href = image_list[place][1];
document.getElementById('LLink').href = image_list[place+4][1];
document.getElementById('MLink').href = image_list[place+8][1];
document.getElementById('RLink').href = image_list[place+12][1];
place++;
var recur_call = "rotateImage("+place+")";
setTimeout(recur_call, interval);
}
<i>
</i> document.getElementById('Timage').alt = image_list[place][2];
... etc...
It's been a few days but I got back to this project. I used your 2nd coding option since it allows me to give a more personalized message for the images. And it works PERFECTLY. Thank a million times again with this.[/QUOTE]
0.1.9 — BETA 5.5