image switching for multiple image sets

Discussion in 'JavaScript' started by johnnyblotter, Jan 22, 2008.

  1. #1
    Man, I'm really having trouble with this. There are two places in my page where I need to enable two separate image switches, each with three images. The image sets need to be rotated by a two separate "next image" links. I got a script that works for one set of images...the thing is, the array shows one set of images, but how can I make this work for ANOTHER set of images on the page...help is greatly appreciated!

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title></title>
    <script type="text/javascript">
    <!--

    var pic_width=322;
    var pic_height=241;
    var thenum=0;

    var ImgAry=['http://www.vicsjavascripts.org.uk/StdImages/One.gif','http://www.vicsjavascripts.org.uk/StdImages/Two.gif'];

    var SRCAry=[];
    for (var zxc0=0;zxc0<ImgAry.length;zxc0++){
    SRCAry[zxc0]=new Image();
    SRCAry[zxc0].src=ImgAry[zxc0];
    }

    function change_it2(zxcid){
    var img=document.getElementById(zxcid);
    img.src=SRCAry[thenum].src;
    img.width=pic_width;
    img.height=pic_height;
    }

    function change_it3(zxcid){
    var img=document.getElementById(zxcid);
    thenum=++thenum%SRCAry.length;
    img.src=SRCAry[thenum].src;
    }

    //-->
    </script>
    </head>

    <body onload="change_it2('img1');">

    <a class="nextimage" href="." onClick="change_it3('img1');return false;" >next image></a>

    <IMG SRC="http://www.vicsjavascripts.org.uk/StdImages/Blank.gif" border="0" id="img1"></body>

    </html>
     
    johnnyblotter, Jan 22, 2008 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    It's inexcusable when scripts have that restriction - try MultiSlide.
     
    Logic Ali, Jan 22, 2008 IP