gli Posted June 25, 2008 Share Posted June 25, 2008 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> Quote Link to comment Share on other sites More sharing options...
lemmin Posted June 25, 2008 Share Posted June 25, 2008 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]; } Quote Link to comment Share on other sites More sharing options...
gli Posted June 25, 2008 Author Share Posted June 25, 2008 thnx! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.