There's a couple of new useful things in this script.
First is new Array.
var song=new Array;
This makes it so I can assign a bunch of values to the array and be able to access it later according to the number.
So in my script I have 6 MIDI addresses stored in the array. I also have the title of the MIDI's store in an array
var title=new Array;
So now I have 6 MIDI addresses and 6 titles stored in Arrays. Now all I need is a random number between 1 and 6 to pick wich MIDI will be played.
This assigns a random number to the variable pl. The random number is less than 1 so now we'll multiply it by 6
Now you need to round it off with this
Now you should have a random number somewhere between 1 and 6. But if the original random number was real small you might end up with a zero wich we havn't assigned anything to song or title wich we could have so now we must make sure pl does not equal zero.
so if pl is smaller than one then pl will equal one. Now we have the number and use the location statement
and then writing the title to the page.
document.writeln("<center>You are listening to "+title[pl]+"</center>");
I could have place this script with in a function to be called when the page is loaded. Here is how you have a function called upon loading of a page.