Jump to content

[SOLVED] Text for each picture in slideshow


gli

Recommended Posts

Hi! I have an array of pictures and array  of text, each for picture.

With pictures i am done and all is okey.

But with text not.

I want that text for imgMid picture shows in 'apDiv1'.

I cant figure out how to do that, maybe somebody can give me the right clue :)

 

var myPix = new Array("images/0.gif","images/one.gif","images/two.gif","images/three.gif","images/four.gif");
var myText = new Array("this is zero","this is one","this is two","this is three","this is four");
function goRight()
{
  myPix.push(myPix.shift());
imgLeft.src = myPix[0];
imgMid.src = myPix[1];
imgRight.src = myPix[2];
}

 

<div id="apDiv1"></div>

You can use the same method that is used on the images to shift the array:

var myPix = new Array("images/0.gif","images/one.gif","images/two.gif","images/three.gif","images/four.gif");
var myText = new Array("this is zero","this is one","this is two","this is three","this is four");
function goRight()
{
myPix.push(myPix.shift());
imgLeft.src = myPix[0];
imgMid.src = myPix[1];
imgRight.src = myPix[2];
myText.push(myText.shift());
apDiv1.innerText = myText[1];
}

 

And the same thing for the goLeft function:

function goLeft()
{
myPix.unshift(myPix.pop());
imgLeft.src = myPix[0];
imgMid.src = myPix[1];
imgRight.src = myPix[2];
myText.unshift(myText.pop());
apDiv1.innerText = myText[1];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.