The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Text randomizer

3 posters

Go down

Solved Text randomizer

Post by Derp-chan 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
Derp-chan
Forumember

Female Posts : 29
Reputation : 1
Language : English

http://forumthingwhatever.forumotion.com/

Back to top Go down

Solved Re: Text randomizer

Post by Ange Tuteur 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
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Text randomizer

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

Yep that worked, thank you!
Derp-chan
Derp-chan
Forumember

Female Posts : 29
Reputation : 1
Language : English

http://forumthingwhatever.forumotion.com/

Back to top Go down

Solved Re: Text randomizer

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

Topic solved and archived


Text randomizer Slgray10

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

Male Posts : 51464
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top


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