The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Text randomizer

View previous topic View next topic Go down

Solved Text randomizer

Post by Derp-chan on July 28th 2015, 6:46 am

Hope this is the right section

Anyways, I wanted to know if there's a way to randomize the text that shows in a forum description. Like it'll change each time the forum is refreshed.

Derp-chan
Forumember

Female Posts : 27
Reputation : 1
Language : English

http://forumthingwhatever.forumotion.com/

Back to top Go down

Solved Re: Text randomizer

Post by Ange Tuteur on July 28th 2015, 10:28 am

Hi @Derp-chan,

You can usually achieve this with some JavaScript. Paste the following code wherever HTML allows scripts to format. Such as an HTML page, module, description, etc..

Code:
<script type="text/javascript">//<![CDATA[
(function() {
  var message = [
    'Message 1',
    'Message 2',
    'Message 3'
  ];
 
  document.write(message[Math.floor(Math.random() * message.length)]);
})();
//]]></script>

It's pretty self explanatory. All you need to do is edit the message variable which contains an array of strings. If you want to add more, simply add a comma after the last message and create a new string with quotes.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Text randomizer

Post by Derp-chan on July 28th 2015, 7:50 pm

Yep that worked, thank you!

Derp-chan
Forumember

Female Posts : 27
Reputation : 1
Language : English

http://forumthingwhatever.forumotion.com/

Back to top Go down

Solved Re: Text randomizer

Post by SLGray on July 28th 2015, 9:35 pm

Topic solved and archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35606
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum