Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple SlideShow on page

Status
Not open for further replies.

lahddah

Programmer
Jan 2, 2003
109
US
There was another thread like this, but slightly different and I didn't find anything that would answer my question..

Can someone tell me how to modify this code to show four slide shows on one page? I've tried copying it four times and changing the chgSlide to chgSlide2, 3, and 4, but when I try to move the code that creates the four different myPix arrays into each function the slides all stop at slide #2. Even though there should be 4 in the array. Hope that makes sense.

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
myPix = new Array("picture1.gif","picture2.gif","picture3.gif","picture4.gif")
thisPic = 0
imgCt = myPix.length - 1

function chgSlide(direction) {
if (document.images) {
thisPic = thisPic + direction
if (thisPic > imgCt) {
thisPic = 0
}
if (thisPic < 0) {
thisPic = imgCt
}
document.myPicture.src=myPix[thisPic]
}
}
</SCRIPT>

Thanks!


~ lahddah
 
will these four slide shows be showing the same pics at the same time?

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
No. There will be different images for each slideshow. I tried to move the 'myPix = new Array..." portion of the code into each function as the array will contain different images. It's at that point that the slide shows only show two images.

Example:

function chgSlide(direction) {
myPix = new Array("picture1.gif","picture2.gif","picture3.gif","picture4.gif")
thisPic = 0
imgCt = myPix.length - 1

if (document.images) {
thisPic = thisPic + direction
if (thisPic > imgCt) {
thisPic = 0
....


function chgSlide2(direction) {
myPix = new Array("picture21.gif","picture22.gif","picture23.gif","picture24.gif")
thisPic = 0
imgCt = myPix.length - 1

if (document.images) {
thisPic = thisPic + direction
if (thisPic > imgCt) {
thisPic = 0
....

function chgSlide3(direction) {
myPix = new Array("picture31.gif","picture32.gif","picture33.gif","picture34.gif")
thisPic = 0
imgCt = myPix.length - 1

if (document.images) {
thisPic = thisPic + direction
if (thisPic > imgCt) {
thisPic = 0
....




~ lahddah
 
You'll need four separate "thisPic" variables as well, otherwise you're basically incrementing/decrementing that valu on each change of each slideshow.

And they should be global (outside the functions) as should be your arrays.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Works excellent. Thank you so much for you help!
Do you know why the arrays and stuff need to be 'global' instead of within each function? Just out of curiousity.




~ lahddah
 
Well, the arrays don't need to. But I'll put it like this:

You're walking down a street and you come up to me. I say, "Hi, my name is Cory." We then become good friends. Now, every time I see you, do I need to say "Hi, my name is Cory."? No, it wastes time and is completely unnecessary. You already know my name, there's no need for you to hear it again, unless you were really drunk.

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
Great way to put it. I got it. Now I need a beer. %-)

Thanks!

~ lahddah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top