View Full Version : Help on making multiple instances of a script work on a page.
09-24-2003, 05:28 PM
I am wanting to put 6 slide shows on one page...however, when I do so using the same script (which is self-contained, no script in the head tag) only the last instance on the page works.
I have tried adding numbers to the end of all the variables that I know of...to no avail.
Would someone mind looking at this page
and giving the code a quick look. I know it's bound to be something simple, I'm just not catching it.
Thanks a ton!
09-24-2003, 05:57 PM
I've got a slideshow that allows multiple instances. My demo page (http://www.peterbailey.net/dhtml/oo_slideshow.htm) has 4, but 6 is certainly possible. Let me know if you like what you see.
09-24-2003, 06:07 PM
I like that a lot actually. What's the catch?:)
09-24-2003, 06:10 PM
Nothing, just keep the copyright in tact, and inform me post-haste of any bugs you might find.
09-24-2003, 06:21 PM
One question....does the slide show allow me to input a separate link for each image in the slideshow...a link that can pop up in a new window? The goal is to have a larger version of each image in the slideshow pop up in a new window.
09-24-2003, 07:25 PM
Yes, the demo page includes a link to the demo w/links.
09-24-2003, 08:35 PM
Oh my dear goodness...this is gonna take a bit to figure out!:D
09-24-2003, 09:23 PM
You won't need to change anyting in the class code - it's just how you create slideshows that changes. I haven't written any docs for this, so lemme know if you get stuck.
09-24-2003, 09:31 PM
I am a bit stuck...
It's doing something very bizarre...as far as I can tell I have placed the 6 shows as you did the 4 on your demo...but only my first show plays...and when it does it plays the first slides really fast and then stops....the rest just load the first image and stop.
Any help would be most appreciated...Here's the test url:
09-24-2003, 09:46 PM
First thing I see wrong is that you're running the play method on the first instance, ss1, each time. You need enact the play method for each instance, so
var delay = 2500;
var imgRoot = 'http://www.craddockcunningham.com/images/job_pics/adapt/';
var ss1 = new SlideShow( 'slide1', 'slide1Link', '', '', imgRoot, 'resiData', 1, 0);
var ss2 = new SlideShow( 'slide2', 'slide2Link', '', '', imgRoot, 'eccData', 1, 0);
var ss3 = new SlideShow( 'slide3', 'slide3Link', '', '', imgRoot, 'commData', 1, 0);
var ss4 = new SlideShow( 'slide4', 'slide4Link', '', '', imgRoot, 'muniData', 1, 0);
var ss5 = new SlideShow( 'slide5', 'slide5Link', '', '', imgRoot, 'adaptData', 1, 0);
var ss6 = new SlideShow( 'slide6', 'slide6Link', '', '', imgRoot, 'indeData', 1, 0);
ss1.play( delay );
ss2.play( delay );
ss3.play( delay );
ss4.play( delay );
ss5.play( delay );
ss6.play( delay );
09-24-2003, 09:54 PM
Okay...in the end they will all have different image roots....so what then? The way you just showed seems to make them all have the same root. I was setting them all up separately as you did in your demo with the 4 shows.
Thanks so much for your help, by the way!!!
09-24-2003, 09:56 PM
Nevermind...if I had payed attention I would have seen what you did...just made those two things reoccuring variables...So, how is that different from how I did it? I had each show play as well.
09-24-2003, 09:58 PM
LOL...maybe I should reserve comment until I actually LOOK at my code...I see what you mean...I still had "ss1" for all 6 instances.
09-24-2003, 09:59 PM
Hehe, no problem.
And yes, I just made the root and delay variables for brevity's sake :D
09-24-2003, 10:03 PM
Okay...Man...this is a good script...
I just added the filters/wipes to them....but I can't upload the working file yet...stupid server is messed up. I will let you know when I get it. Like to get your thumbs up on it.
Are there any other filter effects you can do besides the wipe?
09-24-2003, 10:10 PM
You're gonna want to hurt me by the time this is done...but...
What variable makes it loop? Right now it's getting to the last pic and stopping. It keeps doing the wipe...but the same picture remains.
09-24-2003, 10:41 PM
Originally posted by Tyree
Are there any other filter effects you can do besides the wipe? Yup (http://msdn.microsoft.com/workshop/author/filter/filters.asp). Just know that they only work on IE - other browsers just see a plain image swap.
Ya, let me know when it's uploaded - I'd like to see :D
09-24-2003, 10:42 PM
Just change the last parameter to a boolean true - changing the 0 to a 1 or the literal true will work fine
09-24-2003, 11:14 PM
Thank you soooo much for your help today!!!
I just have a couple more questions:
I have it uploaded now...can you tell me why in IE the last 3 don't play? Gives me an error on line 64, char 3...which, from what I can tell is the play handler for show number 5...any ideas?
Also, is it possible to make the links load in a new window?
09-24-2003, 11:35 PM
Your muniData array has a misplaced comma at the end - just after the last slide, thus creating and empty, "undefined" index.
ABout the links in the new window, you have two options. 1) Just use HTML
<a href="somelink.htm" [B]target="_blank">link</a>Or, 2) Change lines 32 and 33 in the class code
if ( linkId != '' )
this.link = document.getElementById( linkId );To this
if ( linkId != '' )
this.link = document.getElementById( linkId );
this.link.onclick = function()
window.open( this.href, "_blank" );
Additionally, you'd gain some efficiency, readability, and editability but creating variables for your filters and delays.
var delay = 3000;
var fadeFilter = 'progid:DXImageTransform.Microsoft.Fade(duration=1, overlap=0.0)';
var wipeFilter = 'progid:DXImageTransform.Microsoft.GradientWipe(duration=1)';
var ss1 = new SlideShow('slide1','slide1Link','','','images/job_pics/res/','resiData',1,1);
ss1.addFilter( fadeFilter );
ss1.addFilter( wipeFilter );
ss1.play( delay );
var ss2 = new SlideShow('slide2','slide2Link','','','images/job_pics/ecc/','eccData',1,1);
ss2.addFilter( fadeFilter );
ss2.addFilter( wipeFilter );
ss2.play( delay );
09-24-2003, 11:36 PM
Also, since you're using this commercially, I wouldn't balk at a little donation :D
Not required, though - just not my style :cool:
09-25-2003, 12:10 AM
Give me an address and I'll send you some cashola. You definitely deserve it after all your help!
09-25-2003, 07:27 AM
I sent you a PM.
09-25-2003, 03:26 PM
Okay...here's the site close to what the final will be.
Thanks so much for all your help!!!
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.