Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:53:28+00:00 2026-06-01T13:53:28+00:00

i have following code for moving 4 picture around circular way,but it can rotate

  • 0

i have following code for moving 4 picture around circular way,but it can rotate only two of them

<html>
<head>
<title>Moving div</title>
</head>
<body>
<div id = "listDiv">
    <img id="img1" width="200" height="200" /><br />
    <span id="quote1" ></span>
</div>
<div id="listDiv1">
<img id="img2"  width="200" height="200"/><br/>
<span id="quote2 "></span>
</div>
<div id="listDiv2">
<img id="img3" width="200" height="200"/><br/>
<span id="quote3 "></span>
</div>
<div id="listDiv3">
<img id="img4" width="200" height="200"/><br/>
<span id="quote4 "></span>
</div>

<script>

var listDiv = document.getElementById("listDiv");

var lisDiv1=document.getElementById("listDiv1");
var listDiv2=document.getElementById("listDiv2");
var listDiv3=document.getElementById("listDiv3");
var quote1 = document.getElementById("quote1");
var quote2 = document.getElementById("quote2");
var quote3 = document.getElementById("quote3");
var quote4 = document.getElementById("quote4");
var img1 = document.getElementById("img1");
var img2 = document.getElementById("img2");
var img3 = document.getElementById("img3");
var img4 = document.getElementById("img4");
listDiv.style.backgroundColor = "lightBlue";


listDiv.style.position = "absolute";
listDiv1.style.position = "absolute";
listDiv2.style.position = "absolute";
listDiv3.style.position = "absolute";

var intervalHandle = setInterval(changeSecond, 10);

var counter=0;

var pics = [
"http://www.dyslexiaassociation.ca/gallery/famous/AlbertEinstein.jpg",
"http://www.historyking.com/images/Black-Famous-People.jpg",
"http://www.historyking.com/images/Famous-People-From-Washington.jpg",
"http://baobongdaso24h.com/wp-content/uploads/2011/10/Steve-Jobs-chet1.jpg",
"http://www.stgabss.net/SpecialNeeds/images/stories/famous/john_lennon_portrait.jpg",
"http://imgs.inkfrog.com/pix/just4kids2/President-George-W-Bush_mprtp.jpg",
"http://www.smilorama.com/img/people/rare_photos_of_famous_people/rare_photos_of_famous_people04.jpg"
]; 

var quotes = [
'E=mc<sup style="font-size:xx-small">2</sup>',
"I have a dream",
"Be nice to nerds.<br/>Chances are you'll<br/>end up working for one",
"You are holding it wrong",
"Imagine all the people",
"I know the human being<br/>and fish can coexist peacefully.",
"The name is Bond, James Bond"
];


function changeSecond(){
  if (counter++%2==0){
    if (counter>700){
      counter=0;
    }
    //change the text every 101 counts
    if (counter%101==0){
      var randomIndex = Math.floor(Math.random()*pics.length);
      img1.setAttribute("src", pics[randomIndex]);
      quote1.innerHTML=quotes[randomIndex];
       img2.setAttribute("src", pics[randomIndex]);
      quote2.innerHTML=quotes[randomIndex];
       img3.setAttribute("src", pics[randomIndex]);
      quote3.innerHTML=quotes[randomIndex];
       img4.setAttribute("src", pics[randomIndex]);
      quote4.innerHTML=quotes[randomIndex];
    }
    //move the element to the left:
    listDiv.style.left =400+200*Math.cos(counter/90)+"px"; 
    //move the element down:
    listDiv.style.top =400+200*Math.sin(counter/90)+"px"; 
      listDiv1.style.left =400 + 300* Math.cos(counter/90)+"px";
      listDiv1.style.top =400 + 200 * Math.cos(counter/90)+"px";
      listDiv2.style.left =400 + 200 * Math.cos(counter/90)+"px";
      listDiv2.style.top =400 + 200 * Math.cos(counter/90)+"px";
      listDiv3.style.left =400 + 200 * Math.cos(counter/90)+"px";
      listDiv3.style.top =400 + 2width="200" height="200"00 * Math.cos(counter/90)+"px";
  }
}


</script>
</body>
</html>

what can i do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:53:30+00:00Added an answer on June 1, 2026 at 1:53 pm

    There are a few simple errors that are preventing all 4 from showing.

    One is that you have spaces in the span ids for some for the quotes, this was causing errors:

    <span id="quote2 "></span>
    <span id="quote3 "></span>
    <span id="quote4 "></span>
    

    removing the spaces was necessary and it cleared the errors generated. Then there is a typo or copy past mistake here:

      listDiv3.style.top =400 + 2width="200" height="200"00 * Math.cos(counter/90)+"px";
    

    That width= and height= bit is probably a paste mistake while posting or such, but needs to be out.

    So that got 3 showing up at at time nicely and so then it just seems that you have 4 but two are covered by their friends.

    try changing the starting point for each, like this (I made the left have 200, 300, 400, 500 as part of the calculation) :

    listDiv.style.left =400+200*Math.cos(counter/90)+"px"; 
    listDiv.style.top =400+200*Math.sin(counter/90)+"px"; 
    
    listDiv1.style.left =400 + 300 * Math.cos(counter/90)+"px";
    listDiv1.style.top =400 + 200 * Math.cos(counter/90)+"px";
    
    listDiv2.style.left =400 + 400 * Math.cos(counter/90)+"px";
    listDiv2.style.top =400 + 200 * Math.cos(counter/90)+"px";
    
    listDiv3.style.left =400 + 500 * Math.cos(counter/90)+"px";
    listDiv3.style.top =400 + 200 * Math.cos(counter/90)+"px";
    

    this was not very nice looking but it got them uncovered and you can play with it and arrange them better.

    Hope that helps some

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which is parsing a HTML table as simply as
I have the following code. (You can copy it into a file to debug
I have the following code which you can try using c99 filename.c; ./a.out #include
I have the following code which uses the WWW::Mechanize and HTML::TableExtract modules. Everything works
I have following code: <div class='parent'> <div class='left-child'></div> <div class=right-child></div> </div> What I want
I have following code snippet and i am trying to evaluate the time take
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.