Randomly display tips

Noob

New Member
Hi people, please can anyone help me? I have tips (more than one for each page), which i want to display randomly in a block...can this be done? Please help!
 

rwebber77

New Member
Your question is kind of vague, what exactly are you talking about? Tips as in helpful pointers? By block you mean all of the "tips" in one container randomly displaying for a specified time, and then the next loads?
 

Noob

New Member
Your question is kind of vague, what exactly are you talking about? Tips as in helpful pointers? By block you mean all of the "tips" in one container randomly displaying for a specified time, and then the next loads?

In the left sidebar underneath the main menu I have a block in which I display tips relevant to specific articles. Some articles have more than one so I want to display them randomly for that page every time the page refresh :confused:
 

rwebber77

New Member
About the easiest method would be to store all of the text strings within an array in an external file and then use JavaScript's Math.random() to generate random numbers. Those random numbers will represent an index for retrieving a text string from the array, thus changing each time the page loads. Easier to do than to explain, but I hope that points you in the right direction.
 

Noob

New Member
Thank you so much :D I don't know JavaScript but was planning to give it a try anyway. At least now I know what to look for.
 

rwebber77

New Member
No problem! Let us know if you get to your desired end result, otherwise we'll keep you going in the right direction.
 

WD1234567

New Member
You may want to try something like the following...

HTML:
<div id="tipbox">
<p id="tips">
<?php

chooser=(rnd(1,2))

If (chooser==1) {
echo "Tip1 here."
}
else if (chooser==2) {
echo "Tip2 here."
}
end if

?>
</p>
</div>

Granted, I haven't worked with php in awhile so it may be a bit off, but something generally close to that may be helpful.
 
Last edited:
Top