0

Hi there,
I am new in web development. I think this problem is related to javascript. My javascript script is below which changes images after 2 sec. But when i call my start function in img tag in my third row div of my layout, it does not show images in that div or in that area. It show that series of images in first row.

<script>

var images = new Array ("img/1.jpg", "img/2.jpg", "img/3.jpg");
var currentIndex = 0;


function Start()
{
setInterval("ChangeImage()", 2000);
}

function ChangeImage()
{
currentIndex++;
if(currentIndex == images.length)
{
currentIndex = 0;
}

document.images[0].src = images[currentIndex];
}
</script>

first div in html:

<div id="menu">
<img src="header/menu.png" name="menu" id="m"/>
</div>

My slideshow images places here, u can see i have call Start() function in another div.

3rd div html:

<div id="slideshow-img">
<img src="img/3.jpg" name="myimg" id="myimg" onclick="Start()"/>
</div>

Please resolve my problem as soon as possible, I'll highly appreciate.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by SolidSolutions
1

change this line:

document.images[0].src = images[currentIndex];

to this:

document.images[1].src = images[currentIndex];

you see I have change array index to 1. When index is 0 then it changes images for first img tag.

Votes + Comments
clear concise and explained!
1

Hey new_developer,

Sure is great to get a solid answer like that, huh!?! This is a great forum.

Please be sure to marked this thread as solved, and give the responder's post a bump up (the up arrow under the Permalink).

Thanks!

Edited by SolidSolutions: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.