Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't get both scripts to work in simulation

    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.


    Code:
    <!--   <<<<<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>
    Last edited by foufou; 04-23-2004 at 06:11 PM.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by foufou; 04-23-2004 at 04:43 PM.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    already fixed the body tag as soon as Willi told me, but the same result is still happening...

  • #6
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I ask if someone could try the script at his end , maybe the mistake comes just from naming the tables,, ...
    I Apreciate any response.

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #9
    New Coder
    Join Date
    Apr 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Just curious if you tried framesets instead of a table.

    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

  • #10
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    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

  • #11
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #12
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How about merging both scripts into one , and having one function for both slideshows,,
    Is it a good idea, is it possible?
    thx

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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:
    Code:
    <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')">
    Last edited by glenngv; 04-26-2004 at 12:03 PM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •