View Single Post
Old 04-04-2005, 01:22 PM   #4 (permalink)
CSflim
Sky Piercer
 
CSflim's Avatar
 
Location: Ireland
I have very little experience with javascript, and what little I did was quite a while ago, so there is certainly a more elegant way to do this, but here I go:

Code:
<HTML>
<BODY>

<SCRIPT>

num_of_songs = 3

randnum = Math.round(Math.random()*(num_of_songs-1)) + 1

if(randnum == 1){
	filename = "song1.wav";
	songname = "Name of first song";
}else if(randnum == 2){
	filename = "song2.wav";
	songname = "Name of second song";
}else if(randnum == 3){
	filename = "song3.wav";
	songname = "Name of thrd song";
}



document.write("<H2>");
document.write(songname);
document.write("<\H2>");

document.write("<object height=50% width=50% classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95> <param name=AutoStart value=0 /> <param name=FileName value='");

document.write(filename);
document.write("'/></object>");

</SCRIPT>

<P>
<A HREF="javascript:history.go()">Click here to change track</A>

</BODY>
</HTML>

The "change track" link actually refreshes the page, causing a different random number to be picked. This might not be a very satisfactory way of doing it, but its a start at least.

Unfortunately, this method does not lend itself to easily implementing your "Autoplay" check box.
__________________

Last edited by CSflim; 04-04-2005 at 03:07 PM..
CSflim is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46