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>

Link to comment
Share on other sites

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];
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.