I found a testimonial system on a website that i'm trying to copy. I don't understand javascript and am trying to get this working on my site. THE JAVASCRIPT Code: function rotateTestimonials(cur, tot) { if(!($('testimonial'+cur))) return; Element.addClassName('testimonial'+cur, 'hide'); do { cur++; if(cur >= tot) cur = 0; } while(!$('testimonial'+cur)); Element.removeClassName('testimonial'+cur, 'hide'); setTimeout('rotateTestimonials('+cur+','+tot+')', 10000); } I used right click view source to get the HTML Code: <h3>Testimonials</h3> <div id="testimonial0" class="testimonial_large">Some text</div> <div id="testimonial1" class="testimonial_large hide">Some text</div> <div id="testimonial2" class="testimonial_large hide">Some text</div> <div id="testimonial3" class="testimonial_large hide">Some text</div> <script type="text/javascript" src="/js/setup.js"></script> <script type="text/javascript"> setupPage(); <!-- TemplateBeginIf cond="TestimonialsLarge!=''" --> setTimeout('rotateTestimonials(0,4)', 10000); <!-- TemplateEndIf --> </script> What code do I need to put into my html document to get this working?
Javascript Help.
9
I found a testimonial system on a website that i'm trying to copy. I don't understand javascript and am trying to get this working on my site.
THE JAVASCRIPT I used right click view source to get the HTML
What code do I need to put into my html document to get this working?
Can anyone make sense of this script? If so how do I get it to function?
THE JAVASCRIPT
Code:
function rotateTestimonials(cur, tot)
{
if(!($('testimonial'+cur))) return;
Element.addClassName('testimonial'+cur, 'hide');
do { cur++; if(cur >= tot) cur = 0; } while(!$('testimonial'+cur));
Element.removeClassName('testimonial'+cur, 'hide');
setTimeout('rotateTestimonials('+cur+','+tot+')', 10000);
} Code:
<h3>Testimonials</h3>
<div id="testimonial0" class="testimonial_large">Some text</div>
<div id="testimonial1" class="testimonial_large hide">Some text</div>
<div id="testimonial2" class="testimonial_large hide">Some text</div>
<div id="testimonial3" class="testimonial_large hide">Some text</div>
<script type="text/javascript" src="/js/setup.js"></script>
<script type="text/javascript">
setupPage();
<!-- TemplateBeginIf cond="TestimonialsLarge!=''" -->
setTimeout('rotateTestimonials(0,4)', 10000);
<!-- TemplateEndIf -->
</script> Can anyone make sense of this script? If so how do I get it to function?
- donnan
- [1] reply
- brandon2664
- donnan
- brandon2664
- [1] reply
- expertname
- [ 1 ] Thanks
- tuldok
- expertname
- [ 1 ] Thanks
Next Topics on Trending Feed
-
9