...

View Full Version : Can't get my both scripts to work simultanesly



foufou
04-23-2004, 01:50 PM
Hello everyone,
With the help of this forum, i could get my sexy fading-image-slideshow (codelifter.com) script to work exactly as i wanted,thanks again,
Now , that i duplicated the script for puting 2 sliding menus,I've differencialized the variables, ONLOADed them both in my BODY tag;
Result:2 scripts load, but one of them is off,,
My code is attached to my message
I appreciate any help.





<!-- <<<<<MODIFIED>>>>>:
Cross-fade SlideShow <<<WITHOUT>>> Captions
(C)2002 by CodeLifter.com


Browsers: NS4-7,IE4-6
Fade effect only in IE; degrades gracefully.
NS4 shows default caption only.


<html>

<head>



<!--
The <<<<FIRST>>>>>> script in the head of the page.
//-->

<script>

// (C) 2002 http://www.codelifter.com/
// http://www.codelifter.com/
// Free for all users, but leave in this header.

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

var Picture = new Array(); // don't change this


Picture[1] = 'Album011.gif';
Picture[2] = 'Album012.gif';


var tss;
var iss;
var jss = 1;
var pss = Picture.length-1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}

function runSlideShow(){
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=2)";
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad[jss].src;
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
jss = jss + 1;
if (jss > (pss)) jss=1;
tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

</script>







<!--
The following <<<<SECOND>>>>>> script in the head of the page.
//-->

<script>

// (C) 2002 http://www.codelifter.com/
// http://www.codelifter.com/
// Free for all users, but leave in this header.


// Set the slideshow speed (in milliseconds)
var SlideShowSpeed2 = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration2 = 3;

var Picture2 = new Array(); // don't change this


Picture2[1] = 'Album016.gif';
Picture2[2] = 'Album019.gif';

var tss2;
var iss2;
var jss2 = 1;
var pss2 = Picture2.length-1;

var preLoad2 = new Array();
for (iss2 = 1; iss2 < pss2+1; iss2++){
preLoad2[iss2] = new Image();
preLoad2[iss2].src = Picture2[iss2];}

function runSlideShow2(){
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=2)";
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad2[jss2].src;
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
jss2 = jss2 + 1;
if (jss2 > (pss2)) jss2=1;
tss2 = setTimeout('runSlideShow2()', SlideShowSpeed2);
}

</script>





</head>


<body onload="runSlideShow();runSlideShow2()" bgcolor=#000000>


<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=350 height=280>
<img src=Album011.gif name=PictureBox width=350 height=280>
</td>
</tr>
</table>

<table border=0 cellpadding=0 cellspacing=0 left=200>
<tr>
<td width=400 height=400>
<img src=Album019.gif name=PictureBox width=400 height=500>
</td>
</tr>
</table>



</body>

</html>

Willy Duitt
04-23-2004, 02:50 PM
You can only have one onload event handler.
The proper way to call two functions onload is:

eg: <body onload="runSlideShow();runSlideShow2()" ....

Can you please explain what you mean by: but one of them is off
It would be helpful to know what it is not doing or doing what it shouldn't. If there is an error alert It would also be helpful to know what it is and what line the error is on if indicated.

.....Willy

foufou
04-23-2004, 04:39 PM
Thank you, for your reply,
<BODY> tag fixed yet nothing changed,
Haven't found any syntax error in the script, i debuged it with Dreamweaver,
Both Slide shows are displayed on screen , but only one of them start slideshowing,
i've noticed that ,Only the table that i put in its name: PictureBox, runs the slideshow,,, this make it seems that both scripts are ok, but the problem lies in naming both separate tables...i don't know...
Thank you again.

Roy Sinclair
04-23-2004, 05:53 PM
I'd bet you failed to note the little bits Willy Duitt posted that I've highlighted here in red: body onload="runSlideShow();runSlideShow2()"

The latest standards for markup explicitly require the use of quotes for all tag properties because it's impossible to reliably parse tags when the quotes are left out and users add spaces for visual ease of interpreting.

foufou
04-23-2004, 06:14 PM
already fixed the body tag as soon as Willi told me, but the same result is still happening...

foufou
04-24-2004, 07:59 AM
I ask if someone could try the script at his end , maybe the mistake comes just from naming the tables,, ...
I Apreciate any response.

Willy Duitt
04-24-2004, 08:23 AM
I just tried your script which you editted in your first post and there were no errors thrown however, it does not appear that either slideshow is working.

Could you please post a link so someone can see the script run?
It is hard to tell what is going on without any images in the slideshow.

.....Willy

foufou
04-24-2004, 10:32 AM
This is the Url holding it:
http://www.freewebs.com/foufou/index.html

...It seems like both are loaded in the same one table, ....
Thanks in advance

Casseandra
04-24-2004, 11:02 AM
I'm new to this javascript language myself, but my degree (in 7 more credits) is in Web Technology and it seems to me that it would be easier to target your slide shows to frame sets instead of to two tables in one page. Because in a frameset you would actually have to specify that you want certain things to happen in the left frame, right frame, top frame etc.

You could still put your slide shows inside separate tables, but each slide show would be its own html page, then target the first slide show html page to the left frame, and the second slide show html page to the right frame, make it so the frameset frames are of equal size, doesn't have any borders, noresize, and no scrolling and the slide shows would be side by side. (Might also solve the problem of both shows trying to run in the same table)

Its a thought, can't guarantee it would work, just figure it might be easier that way. (Although I know a lot of people do not like frames, done right most would never know it was frames.)

Casseandra

Willy Duitt
04-24-2004, 10:45 PM
The problem is you have two images named PictureBox.

Change all instances of PictureBox in the second script to PictureBox2 and it should work.

eg:


function runSlideShow2(){
if (document.all){
document.images.PictureBox2.style.filter="blendTrans(duration=2)";
document.images.PictureBox2.filters.blendTrans.Apply();}
document.images.PictureBox2.src = preLoad2[jss2].src;
if (document.all) document.images.PictureBox2.filters.blendTrans.Play();
jss2 = jss2 + 1;
if (jss2 > (pss2)) jss2=1;
tss2 = setTimeout('runSlideShow2()', SlideShowSpeed2);
}


<img src=eliza1.jpg name=PictureBox2 width=350 height=280>

And you really need tp quote all of your attributes. This is a bad habit and not only will your pages not validate, but you will find that the failure to properly quote your attributes will cause you problems.

.....Willy

foufou
04-25-2004, 09:01 AM
It worked Finally! thank you willy,!!
Cassendra, thank u too, ur suggestion was indeed helpfulf, and it was my alternative, if the script didn't work at all,

Just one lillte question still remaining, the following variables are set equaled values in both scripts:
var SlideShowSpeed = 3000;

var CrossFadeDuration = 3;

document.images.PictureBox.style.filter="blendTrans(duration=2)

-What makes the 2 slideshows running unsimultaneously?
Thank u a lot.

foufou
04-26-2004, 11:31 AM
How about merging both scripts into one , and having one function for both slideshows,,
Is it a good idea, is it possible?
thx

glenngv
04-26-2004, 11:55 AM
Actually, there is a mistake on that script. It starts populating the array at index 1 leaving the element at 0 useless.

Here's the generic script:


<script type="text/javascript">

// (C) 2002 http://www.codelifter.com/
// http://www.codelifter.com/
// Free for all users, but leave in this header.
// Modified by glenngv

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

var Picture = new Array("Album011.gif","Album012.gif","Album013.gif"); //add as many images as desired

var tss;
var jss = 0;
var pss = Picture.length;

var preLoad = new Array();
for (var iss = 0; iss < pss; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];
}

function runSlideShow(imgName){
if (document.all){
document.images[imgName].style.filter="blendTrans(duration=2)";
document.images[imgName].filters.blendTrans.Apply();
}
document.images[imgName].src = preLoad[jss].src;
if (document.all) document.images[imgName].filters.blendTrans.Play();
jss++;
if (jss >= pss) jss=0;
tss = setTimeout(function(){runSlideShow(imgName)}, SlideShowSpeed);
}

</script>
...
<body onload="runSlideShow('PictureBox'); runSlideShow2('PictureBox2')">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum