Shoutbox

Random Quote into HTML - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Random Quote into HTML (/showthread.php?tid=57041)

Random Quote into HTML by Joe on 03-16-2006 at 07:33 PM

I want to make a line of text randomly selected out of preset choices... like sloganizer does with images... but i just want a line of text to do this. How would I go about this?


RE: Random Quote into HTML by ShawnZ on 03-16-2006 at 07:38 PM

<script>quotes = new Array();void(document.write("<div id=\"quotespace\"></div>"));

    quotes.push("a");
    quotes.push("b");
    quotes.push("c");
    quotes.push("d");
    quotes.push("e");
    ...etc

document.getElementById("quotespace").innerHTML = quotes[Math.round(Math.random * quotes.length)]</script>


RE: Random Quote into HTML by henri on 03-16-2006 at 07:41 PM

Well You Can Do It In Php Here Is An Example
(This Has Been Tested On Php 4 And 5)

code:
<?php
$tip = rand(1,2); //Change The 2 To The Number Of Tip`s

if ($tip == 1) { //Tip 1
echo '<!--Insert Tip #1 Here-->';
}
if ($tip == 2) { //Tip 2
echo '<!--Insert Tip #2 Here-->';
}
?>

If You Have Any Problems Pm Me.
RE: Random Quote into HTML by Eljay on 03-16-2006 at 07:45 PM

tbh in php it should be...

code:
<?php
$quotes = array('Quote 1', 'Quote 2');

echo $quotes[rand(0, count($quotes)-1)];
?>