How can I make a div block rotate for a testimonials section? (Text rotator)

I have been combing the Internet for text rotators but none of them really meet my needs. I have a testimonials section on a site and I need it to rotate through all of them (about 60).

My testimonials section code looks like this:

<div id="Testimonials">
      <div><a href="Testimonials.aspx"><img src="images/header_small_testimonials.gif" style="padding-top:15px; padding-left:5px; border:0px;" /></a></div>
                  
      <div id="TestimonialsText"><strong>Name</strong></div>
      <div style="color:#333333; font-size:10px; margin-bottom:5px; padding-left:5px;">Title<br />Company</div>
          <div style="padding-left:5px;">Text of testimonial <br /><a href="Testimonials.aspx">Read More</a>. </div>
</div>

*** I will be replacing inline styles with classes soon....just fyi

I need the ID #Testimonials div to rotate.

I have found ways to rotate words or sentences but the rotated text is placed within the JS and I cannot put div's inside of JS.

Any suggestions?

Thanks
IShivaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IShivaAuthor Commented:
This is from a previous solution posted by Eternal Student. This is exactly what I need HOWEVER, can some edit the code so that the rotation is random? Currently, on refresh or load it starts at #1 then changes. (1,2,3 etc). I would like the order of rotation to be random.

Can anyone add that to this code?

Thanks much!!!
0
IShivaAuthor Commented:
*** here is the code***

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
      <head>
            <title>Example</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <script type="text/javascript">      
                  var mycontent=new Array()
                  mycontent[0]='<div id="one">Text1</div>'
                  mycontent[1]='<div id="two">Text2</div>'
                  mycontent[2]='<div id="three">Text3</div>'
                  mycontent[3]='<div id="four">Text4</div>'
                 
                  var i=0
                 
                  function altercontent(){
                        if (document.all)
                        dcontent.innerHTML=mycontent[i];
                  else if (document.getElementById){
                        rng = document.createRange();
                        el = document.getElementById("dcontent");
                        rng.setStartBefore(el);
                        htmlFrag = rng.createContextualFragment(mycontent[i]);
                  while (el.hasChildNodes()) el.removeChild(el.lastChild);
                  el.appendChild(htmlFrag);}
                 
                  i=(i==mycontent.length-1)? 0 : i+1
                  setTimeout("altercontent()", 3000)
                  }
                 
                  window.onload=altercontent      
            </script>

      </head>
      <body>
     
            <div id="dcontent" style="width:780px; background-color: #E2E2FC; padding: 5px"></div>

      </body>
</html>
0
ritetekCommented:
Change 'i=(i==mycontent.length-1)? 0 : i+1' to 'i=Math.floor(Math.random()*mycontent.length)'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.