jeffman Posted April 6, 2011 Share Posted April 6, 2011 If it works, it works. Experienced programmers won't do it that way because it's not scalable. If you suddenly decided to add 15 quotes to your array, you'd have to add 15 new functions . . . If you can get the other code working, all you would have to do is change the array. The code will still work. Link to comment Share on other sites More sharing options...
fondaa93 Posted April 6, 2011 Author Share Posted April 6, 2011 Yeah that's what I'm kind of worried about because as we continue to make sales we will continue to get testimonials that we will want to use on our website.. Would you mind posting the updated code that worked for you and I will try to figure out how to get it to work on our website? Sorry for being such a bother.. Link to comment Share on other sites More sharing options...
jeffman Posted April 6, 2011 Share Posted April 6, 2011 This is mostly thescientist's code with a few corrections and tweaks. Tested in FF and Chrome. Note: there are a few places where a seasoned developer might combine a few statements. <html><head> <title>Text Slideshow in javascript</title> <style type="text/css"> #quotation{ margin: 0px 20px; padding-top: 20px; font-size: 1.1em; font-style: italic; } </style> <script type="text/javascript"> var slideArray = new Array(); slideArray[0]= "One"; slideArray[1]= "Two"; slideArray[2]= "Three"; var arrayLength = slideArray.length; //equals 3 var currentIndex = arrayLength; //will also equals 3 function display(){ var quoteEle= document.getElementById('quotation'); currentIndex++; //increments the value of currentIndex by 1, i.e. currentIndex = currentIndex + 1 if(currentIndex >= arrayLength){ //wraps if currentIndex goes "out of bounds" currentIndex = 0; }; var quote = slideArray[currentIndex]; //gets a quote at the index specified by currentIndex's value quoteEle.innerHTML = quote; setTimeout(display, 5000); } window.onload = display; </script> </head><body><div id="div_display"> <p id="quotation"></p></div></body></html> Link to comment Share on other sites More sharing options...
fondaa93 Posted April 6, 2011 Author Share Posted April 6, 2011 Hey, thank you so so so much!! Both of you! It works like a champ, I installed it in our website and it looks great!I pray God will richly bless you, since I have no idea how else to repay you. Thanks again!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.