AlterEgo
02-02-2005, 10:26 PM
I have an array, variable name "lyrics". What I'm trying to do is display a random lyric every time the user visits the page. I'm using this script:
var line = lyrics.length;
var whichline=Math.round(Math.random()*(line - 1));
function showlyric(){document.write(lyrics[whichline]);}
showlyric();}
But this always shows just the first lyric in the array, even after refreshing. Also, the lyric is the only thing that shows on the page, even though I have the script inside the table cell that I want it in. So basically it's just a big horrible mess and so I was wondering if someone would be able to point me in the right direction? Thanks.
var line = lyrics.length;
var whichline=Math.round(Math.random()*(line - 1));
function showlyric(){document.write(lyrics[whichline]);}
showlyric();}
But this always shows just the first lyric in the array, even after refreshing. Also, the lyric is the only thing that shows on the page, even though I have the script inside the table cell that I want it in. So basically it's just a big horrible mess and so I was wondering if someone would be able to point me in the right direction? Thanks.