Rotate image javascript

Posted on 2011-05-03
Last Modified: 2012-05-11

I have created a simple page in Dreamweaver that displays six images across the page. I want each of these six images to rotate with four different images. I have found this javascript but simply do not know how to get it working.

Should I have an image called Picture(1).jpg or is this (1) part of the array?
Where should these images be placed?
Also, should img src ="" remain, or do I need to replace this with the name of an existing image?

Any help would be appreciated.

  <title>Image Rotate
  <img src="" name="Rotating" id="Rotating1" width=100 height=100>
  <img src="" name="Rotating" id="Rotating2" width=100 height=100>
  <script language="JavaScript">
  var ImageArr1 = new Array("Picture(3).jpg","Picture(1).jpg","Picture(2).jpg");
  var ImageHolder1 = document.getElementById('Rotating1');
  var ImageArr2 = new Array("Picture(5).jpg","Picture(6).jpg","Picture(7).jpg");
  var ImageHolder2 = document.getElementById('Rotating2');
  function RotateImages(whichHolder,Start)
        var a = eval("ImageArr"+whichHolder);
        var b = eval("ImageHolder"+whichHolder);
        b.src = a[Start];
Question by:OZSJ
    1 Comment
    LVL 5

    Accepted Solution

    <div id="home-photo"><img src="song.JPG" id="photo" alt=""></div>

    <script language="JavaScript">
    var ImageArr1 = new Array("12.jpg","13.jpg","07.jpg");
    var ImageHolder1 = document.getElementById("photo");

    function RotateImages(whichHolder,Start)
    var a = eval("ImageArr"+whichHolder);
    var b = eval("ImageHolder"+whichHolder);
    b.src = a[Start];
    window.setTimeout("RotateImages("+whichHolder+","+ (Start+1)+")",3500);


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    jQuery Popover 4 363
    Problem to the codes 19 95
    jquery toggle display styling 5 74
    javascript, button, count 6 85
    In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now