Im having problems with the script below.
Im trying to insert the HTML script in different areas of my site to place different sizes of rotating banner ads for advertising purposes but its only showing me the one size only. Example I inserted the script using the 728x90 banner ad in one area and a 468x60 banner ad in another area. Then the script for the 468x60 is replacing the 728x90 banners so it only shows one.
I was hoping a kind professional could help me make this script that i can insert in more than location on each page.
So the million dollar question is: What is it that i have to change or add or both that i could use this banner rotator script multiple times in the same page?? So I'm not sure what to change in the script to distinguish between the two or three and keep them separate.
Below is the example of my issue.
www.trisportworld.com/test.html
Below is the unedited version of the script
<script >
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}
link = new initArray(
"http://example.com/page1",
"http://example.com/page2",
"http://example.com/page3",
"http://example.com/page4",
"http://example.com/page5",
"http://example.com/page6"
);
image = new initArray(
"http://example.com/images/banner_1.jpg",
"http://example.com/images/banner_2.jpg",
"http://example.com/images/banner_3.jpg",
"http://example.com/images/banner_4.jpg",
"http://example.com/images/banner_5.jpg",
"http://example.com/images/banner_6.jpg"
);
text = new initArray(
"Example 1 Title",
"Example 2 Title",
"Example 3 Title",
"Example 4 Title",
"Example 5 Title",
"Example 6 Title"
);
function getRandom(){
var core = Math.floor(Math.random()*6); // amount of items in array
displayBanner(core)
}
function displayBanner(theNum){
var ranlink = link[theNum];
var ranimage = image[theNum];
var rantext = text[theNum];
//document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>');
document.getElementById('theImg').alt=rantext;
document.getElementById('theImg').src=ranimage;
document.getElementById('theLink').href=ranlink;
}
</script>
<a href="#" target="_blank" id="theLink"><img src="" border="0" alt="" id="theImg"></a>
<script >
getRandom();
setInterval("getRandom()", 6000);
</script>
Edited by club777, 27 May 2013 - 07:30 AM.