FireHeaven
09-21-2007, 08:14 AM
Hello everyone. I'm relatively new to JavaScript. I've toyed a little with it...but I suppose that doesn't matter.
I'm attempting to make a gift, sort of a random memory generator that'll pull up text and/or a picture and/or a movie and/or a song. I know it seems a little...much? But I'm having trouble trying to figure out how. I got the text part down, and I think I can do all of them...but not together. Here's the code I've been trying to work with.
<DIV id="memorytext">Click the button below...</DIV>
<IMG id="memory2" border="0">
<script type="text/javascript">
function rand ( n )
{
return ( Math.floor ( Math.random ( ) * n + 1 ) );
}
var our_memories = new Array ( );
our_memories[0] = "If music be the food of love, play on";
our_memories[1] = "When shall we three meet again...?";
our_memories[2] = "What a piece of work is man!";
our_memories[3] = "There's daggers in men's smiles";
our_memories[4] = "Alas, poor Yorick! I knew him, Horatio";
our_memories[5] = "Time shall unfold what plaited cunning hides";
our_memories[6] = "Goodnight, goodnight! Parting is such sweet sorrow";
our_memories[7] = "Friends, Romans, countrymen, lend me your ears";
our_memories[8] = "I am dying, Egypt, dying";
our_memories[9] = "Get thee to a nunn'ry";
our_memories[10] = "Heya!";
our_memories[11] = "<B>Get thee to a nunn'ry222222222222222</B> http://i5.tinypic.com/4le874k.gif";
function pick_memory ( )
{
var DisplayText = our_memories[rand(12)-1];
document.getElementById("memorytext").innerHTML = DisplayText;
document.getElementById("memorypic").src = DisplayText;
}
</script>
<form><input type="button" name="test" value="Click me" onclick="pick_memory ( )"></form>
Any help would be appreciated...I've been toying with it for four hours now. ^^; I know, I suck. And ignore the random quotes on there...
I'm attempting to make a gift, sort of a random memory generator that'll pull up text and/or a picture and/or a movie and/or a song. I know it seems a little...much? But I'm having trouble trying to figure out how. I got the text part down, and I think I can do all of them...but not together. Here's the code I've been trying to work with.
<DIV id="memorytext">Click the button below...</DIV>
<IMG id="memory2" border="0">
<script type="text/javascript">
function rand ( n )
{
return ( Math.floor ( Math.random ( ) * n + 1 ) );
}
var our_memories = new Array ( );
our_memories[0] = "If music be the food of love, play on";
our_memories[1] = "When shall we three meet again...?";
our_memories[2] = "What a piece of work is man!";
our_memories[3] = "There's daggers in men's smiles";
our_memories[4] = "Alas, poor Yorick! I knew him, Horatio";
our_memories[5] = "Time shall unfold what plaited cunning hides";
our_memories[6] = "Goodnight, goodnight! Parting is such sweet sorrow";
our_memories[7] = "Friends, Romans, countrymen, lend me your ears";
our_memories[8] = "I am dying, Egypt, dying";
our_memories[9] = "Get thee to a nunn'ry";
our_memories[10] = "Heya!";
our_memories[11] = "<B>Get thee to a nunn'ry222222222222222</B> http://i5.tinypic.com/4le874k.gif";
function pick_memory ( )
{
var DisplayText = our_memories[rand(12)-1];
document.getElementById("memorytext").innerHTML = DisplayText;
document.getElementById("memorypic").src = DisplayText;
}
</script>
<form><input type="button" name="test" value="Click me" onclick="pick_memory ( )"></form>
Any help would be appreciated...I've been toying with it for four hours now. ^^; I know, I suck. And ignore the random quotes on there...