Help - Search - Members - Calendar
Full Version: Text Rotator
Zymic Webmaster Forums > Web Design & Development > Client Side Scripting > JavaScript
Nexus
How do I edit this JavaScript Text Rotator so that it won't display quotes at random? I wanted something else but I edited it as it'd make no sence to have it.

So far this is what I've got (naturally, the quotes are different than what the site put that I got it from).

CODE
<script language="JavaScript">
function rotateEvery(sec)
{
    var Quotation=new Array()

    // QUOTATIONS
    Quotation[0] = "Have you had your daily dose of Leetbix today?";
    Quotation[1] = "It's like a Randomtastic Adventure, man!";
    Quotation[2] = "Mr. Jiggles says Hi and welcome to his website!";
    Quotation[3] = "WARNING: This site is not recommended for children.";
    Quotation[4] = "Or adults, for that matter...";

    var which = Math.round(Math.random()*(Quotation.length - 1));
    document.getElementById('textrotator').innerHTML = Quotation[which];
    
    setTimeout('rotateEvery('+sec+')', sec*3000);
}
</script>


All help = Greately appreciated. And Mr. Jiggles shall commemorate you for it when he feels like it. I shall commemorate you in a post if you help me. Either way, we both shall be appreciative.
Nexus
Yes, I wish for them to be cycled in the order they're made in.

So Quotation[0] is first, Quotation[1] is second, and this continues all the way to Quotation[4] (well, actually 10 as I've edited it lol).

Also, is there any way to make it so that the text doesn't rotate unless someone refreshes the page? So like, it changes the quote when somebody hits Refresh, presses F5 or leaves the page and then comes back again?
Nexus
Thanks man, much appreciated.
IamShipon1988
Heh this is a nice one. I wonder if there are any like this in php. It doesn't seem too hard of a script.
bekdesignsdotcom
Hello,
A script I am using on a clients say is the following:

CODE
<script language="JavaScript">



var Quotation=new Array()



Quotation[0] = "My training at Synergy Sports and fitness helped me achieve All state Football this season, All-District Basketball last season and 2nd in state in the 200.<br>-Josh Dupree";

Quotation[1] = "Training at Synergy has made me stronger; I just won the Goblin Gallop.<br>-Drew & Ryan Savage";

Quotation[2] = "Synergy has really improved my tennis game. I’m serving better, I’m covering the court better, and I’m finishing.<br>-Karan Padda";

Quotation[3] = "Synergy Sports and Fitness has really helped my speed and agility in and out of the water for the past 3 years. Thanks to Synergy we really are competitive.<br>-Holly & Lindy Williams";

Quotation[4] = "Synergy definitely has helped me become stronger and longer off the tee with my golf game.<br>-Emily Gedert";

Quotation[5] = "I played 4 years of professional hockey here in Toledo and over the summer I come to Synergy Sports and Fitness because it’s the best place in the area for hockey oriented and specific training.<br>-Nick Parillo";

Quotation[6] = "Playing basketball and synergy has really helped me improve my quickness on the court.<br>-Tiffany Scott";

Quotation[7] = "To play at the collegiate level you need speed and explosiveness. Synergy Sports and Fitness has helped me develop that.<br>-Christine Auberle";




var Q = Quotation.length;

var whichQuotation=Math.round(Math.random()*(Q-1));

function showQuotation(){document.write(Quotation[whichQuotation]);}

showQuotation();

</script>



He would like it so there can be images in it too, so the person who is saying the quote an image will show up with it too
http://bekdesigns.com/synergy/layout/index.php?act=home
there is an example of what i'm talking about. Thats the site im working on. The top where it shows the picture and then the quote. I need a picture of that sort next to each quote. I've tried to put an image in this script and of course it doesnt work.

Any help would be appreciated.

Thank you!
bekdesignsdotcom
What do you mean?


Quotation[0] = "<img src="imagehere.jpg"> My training at Synergy Sports and fitness helped me achieve All state Football this season, All-District Basketball last season and 2nd in state in the 200.<br>-Josh Dupree";


I tried that.... which didnt work.
Valency
I think the image would go before the Quotation.. I not too good with script, Just a suggestion.

Regards, Valency.
bekdesignsdotcom
That worked!

Thank you very much for your help! It was mucho appreciated.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.