[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

This simple image rotator javascript isn't working -can anyone find an error?

<script type="text/javascript"><!--
var imgs5 = new Array(
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-2-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-4-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-5-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-6-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-7-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-8-final.jpg");

var lnks5 = new Array(
"http://www.pressroomgraphics.com.au/machines/uv-varnish/1600-uv-vanishing-machine/",
"http://www.pressroomgraphics.com.au/machines/guillotines/touch-screen-double-hydraulic-double-guide-guillotine/",
"http://www.pressroomgraphics.com.au/machines/guillotines/480mm-guillotine/",
"http://www.pressroomgraphics.com.au/machines/guillotines/qzk1370/",
"http://www.pressroomgraphics.com.au/inks/",
"http://www.pressroomgraphics.com.au/machines/diecutting-creasing/auto-folder-creaser/");

var alt5 = new Array(
"1600MM UV Vanishing Machine",
"920MM Guillotine",
"480MM Guillotine",
"1370MM Guillotine",
"Matt UV Vanish Coating",
"Auto Folder Creaser");

var currentAd5 = 0;

var imgCt5 = 5;
function cycle5() {
if (currentAd5 == imgCt5) {
currentAd5 = 0;
}
var banner5 = document.getElementById('adBanner5');
var link5 = document.getElementById('adLink5');
banner5.src=imgs6[currentAd5]
banner5.alt=alt5[currentAd5]
document.getElementById('adLink5').href=lnks5[currentAd5]
currentAd5++;
}
window.setInterval("cycle5()",7000);
// -->
</script>

This site is using it
http://www.pressroomgraphics.com.au

Thanks
0
Amanda Watson
Asked:
Amanda Watson
  • 4
1 Solution
 
leakim971PluritechnicianCommented:
replace :
banner5.src=imgs6[currentAd5]
by :
banner5.src=imgs5[currentAd5]
0
 
Amanda WatsonAuthor Commented:
Hi there, that didn't change anything at all

There are 6 images in the array - what else could be stopping this from working?
0
 
Amanda WatsonAuthor Commented:
Hang on that did fix it thanks
So how can I add a new iamge and link here safely?>
0
 
Amanda WatsonAuthor Commented:
I just added another image and it isn't showing?
<script type="text/javascript"><!--
var imgs5 = new Array(
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-2-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-4-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-5-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-6-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-7-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-8-final.jpg",
"http://www.pressroomgraphics.com.au/wp-content/uploads/pressroom-banner-9-final.jpg");

var lnks5 = new Array(
"http://www.pressroomgraphics.com.au/machines/laminating/1600-uv-liquid-laminator/",
"http://www.pressroomgraphics.com.au/machines/guillotines/touch-screen-double-hydraulic-double-guide-guillotine/",
"http://www.pressroomgraphics.com.au/machines/guillotines/480mm-guillotine/",
"http://www.pressroomgraphics.com.au/machines/guillotines/qzk1370/",
"http://www.pressroomgraphics.com.au/inks/",
"http://www.pressroomgraphics.com.au/machines/diecutting-creasing/auto-folder-creaser/",
"http://www.pressroomgraphics.com.au/machines/guillotines/ar670v-fullar-hydraulic-guillotine/");

var alt5 = new Array(
"1600MM UV Vanishing Machine",
"920MM Guillotine",
"480MM Guillotine",
"1370MM Guillotine",
"Matt UV Vanish Coating",
"Auto Folder Creaser",
"AR670V Fullar Hydraulic Gullotine");

var currentAd5 = 0;

var imgCt5 = 5;
function cycle5() {
if (currentAd5 == imgCt5) {
currentAd5 = 0;
}
var banner5 = document.getElementById('adBanner5');
var link5 = document.getElementById('adLink5');
banner5.src=imgs5[currentAd5]
banner5.alt=alt5[currentAd5]
document.getElementById('adLink5').href=lnks5[currentAd5]
currentAd5++;
}
window.setInterval("cycle5()",7000);
// -->

What do I need to change to get it to show?
0
 
Amanda WatsonAuthor Commented:
Thank you all sorted ;-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now