View Single Post
Old 10-09-2012, 03:00 PM   PM User | #3
cmyk529
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
cmyk529 is an unknown quantity at this point
Code:
<!DOCTYPE html>
<html>
<body>
    

<p id="generator">Generate a random fact</p>

<button onclick="myFunction()">Try it</button>

<div id="content">
   <script type="text/javascript">
    function changeText(){
	document.getElementById('boldStuff').innerHTML = r_text[i];
}
</div>

<div id="random">   
<script>
Array.prototype.myUcase=function()
{
for (i=0;i<this.length;i++)
  {
  this[i]=this[i].toUpperCase();
  }
}

function myFunction()
{
var r_text = new Array ();
r_text[0] = "Give a homeless man a gift card";
r_text[1] = "Hold the door for a stranger";
r_text[2] = "Pay for a stranger's lunch";
r_text[3] = "Compliment the next person you see";
r_text[4] = "Take your neighbor's dog for a walk";
r_text[5] = "Send greeting cards to random addresses";
r_text[6] = "Load a vending machine with money";
var i = Math.floor(7*Math.random())

document.getElementById('boldStuff').innerHTML = r_text[i];
}

</script>
</div>

</body>
</html>

<script language="JavaScript">
<!--

//-->
</script>

Not sure if I've done this correctly.
cmyk529 is offline   Reply With Quote