Results 1 to 4 of 4

Thread: Need Help with Left-Right Image Slideshow Script

  1. #1
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need Help with Left-Right Image Slideshow Script

    I tried to modify this code but I keep getting and undefined text on it and some of my pictures don't load.

    Can someone help me with this:

    <body>

    <script language="JavaScript1.2">

    var scrollerwidth='300px'
    var scrollerheight='300px'
    var scrollerbgcolor='white'
    //4000 miliseconds=4 seconds
    var pausebetweenimages=3000

    var slideimages=new Array()
    slideimages[1]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio1.jpg">'
    slideimages[2]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio2.jpg ">'
    slideimages[3]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio3.jpg">'
    slideimages[4]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio4.jpg">'
    slideimages[5]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio5.jpg">'
    slideimages[6]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio6.jpg">'
    slideimages[7]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio7.jpg">'
    slideimages[8]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio8.jpg">'
    slideimages[9]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio9.jpg">'
    slideimages[10]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio10.jpg">'
    slideimages[11]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio11.jpg">'
    slideimages[12]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio12.jpg">'
    slideimages[13]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio13.jpg">'


    var ie=document.all
    var dom=document.getElementById

    if (slideimages.length>1)
    i=2
    else
    i=0

    function move1(whichlayer){
    tlayer=eval(whichlayer)
    if (tlayer.left>0&&tlayer.left<=5){
    tlayer.left=0
    setTimeout("move1(tlayer)",pausebetweenimages)
    setTimeout("move2(document.main.document.second)",pausebetweenimages)
    return
    }
    if (tlayer.left>=tlayer.document.width*-1){
    tlayer.left-=5
    setTimeout("move1(tlayer)",50)
    }
    else{
    tlayer.left=parseInt(scrollerwidth)+5
    tlayer.document.write(slideimages[i])
    tlayer.document.close()
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function move2(whichlayer){
    tlayer2=eval(whichlayer)
    if (tlayer2.left>0&&tlayer2.left<=5){
    tlayer2.left=0
    setTimeout("move2(tlayer2)",pausebetweenimages)
    setTimeout("move1(document.main.document.first)",pausebetweenimages)
    return
    }
    if (tlayer2.left>=tlayer2.document.width*-1){
    tlayer2.left-=5
    setTimeout("move2(tlayer2)",50)
    }
    else{
    tlayer2.left=parseInt(scrollerwidth)+5
    tlayer2.document.write(slideimages[i])
    tlayer2.document.close()
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function move3(whichdiv){
    tdiv=eval(whichdiv)
    if (parseInt(tdiv.style.left)>0&&parseInt(tdiv.style.left)<=5){
    tdiv.style.left=0+"px"
    setTimeout("move3(tdiv)",pausebetweenimages)
    setTimeout("move4(scrollerdiv2)",pausebetweenimages)
    return
    }
    if (parseInt(tdiv.style.left)>=tdiv.offsetWidth*-1){
    tdiv.style.left=parseInt(tdiv.style.left)-5+"px"
    setTimeout("move3(tdiv)",50)
    }
    else{
    tdiv.style.left=scrollerwidth
    tdiv.innerHTML=slideimages[i]
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function move4(whichdiv){
    tdiv2=eval(whichdiv)
    if (parseInt(tdiv2.style.left)>0&&parseInt(tdiv2.style.left)<=5){
    tdiv2.style.left=0+"px"
    setTimeout("move4(tdiv2)",pausebetweenimages)
    setTimeout("move3(scrollerdiv1)",pausebetweenimages)
    return
    }
    if (parseInt(tdiv2.style.left)>=tdiv2.offsetWidth*-1){
    tdiv2.style.left=parseInt(tdiv2.style.left)-5+"px"
    setTimeout("move4(scrollerdiv2)",50)
    }
    else{
    tdiv2.style.left=scrollerwidth
    tdiv2.innerHTML=slideimages[i]
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function startscroll(){
    if (ie||dom){
    scrollerdiv1=ie? first2 : document.getElementById("first2")
    scrollerdiv2=ie? second2 : document.getElementById("second2")
    move3(scrollerdiv1)
    scrollerdiv2.style.left=scrollerwidth
    }
    else if (document.layers){
    document.main.visibility='show'
    move1(document.main.document.first)
    document.main.document.second.left=parseInt(scrollerwidth)+5
    document.main.document.second.visibility='show'
    }
    }

    window.onload=startscroll

    </script>




    <ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}; visibility=hide>
    <layer id="first" left=1 top=0 width=&{scrollerwidth}; >
    <script language="JavaScript1.2">
    if (document.layers)
    document.write(slideimages[0])
    </script>
    </layer>
    <layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
    <script language="JavaScript1.2">
    if (document.layers)
    document.write(slideimages[1])
    </script>
    </layer>
    </ilayer>

    <script language="JavaScript1.2">
    if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+'">')
    document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
    document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:1px;top:0px;">')
    document.write(slideimages[0])
    document.writeln('</div>')
    document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px">')
    document.write(slideimages[1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
    }
    </script>

    <p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>
    <a href="http://dynamicdrive.com">Dynamic Drive</a></font></p>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I only get the one 'undefined' and that is because you left out zero in the array, after that it seems to work (until it gets back to the beginning). Change it to this:
    Code:
    var slideimages=new Array()
    slideimages[0]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio1.jpg">'
    slideimages[1]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio2.jpg ">'
    slideimages[2]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio3.jpg">'
    slideimages[3]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio4.jpg">'
    slideimages[4]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio5.jpg">'
    slideimages[5]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio6.jpg">'
    slideimages[6]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio7.jpg">'
    slideimages[7]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio8.jpg">'
    slideimages[8]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio9.jpg">'
    slideimages[9]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio10.jpg">'
    slideimages[10]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio11.jpg">'
    slideimages[11]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio12.jpg">'
    slideimages[12]='<img src="http://www.mawebcenters.com/tuccelliphotography/portfolio13.jpg">'
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks John, I will try that

  4. #4
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    it works, I think I tried that before but anyway now it works...

    thanks so much

Bookmarks

Posting Permissions

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