[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Rotate image javascript

Posted on 2011-05-03
1
Medium Priority
?
491 Views
Last Modified: 2012-05-11
Hi,

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.

<html>
  <head>
  <title>Image Rotate
  </head>
 
  <body>
  <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);
        if(Start>=a.length)
              Start=0;
        b.src = a[Start];
        window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",1500);
  }
 
  RotateImages(1,0);
  RotateImages(2,0);
 
  </script>
 
  </body>
  </html>
0
Comment
Question by:OZSJ
1 Comment
 
LVL 5

Accepted Solution

by:
eNarc earned 2000 total points
ID: 35512001
<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);
if(Start>=a.length)
Start=0;
b.src = a[Start];
window.setTimeout("RotateImages("+whichHolder+","+ (Start+1)+")",3500);
}

RotateImages(1,0);
</script>
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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