Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

CGI for Midis?

I would like to have a random midi play on my webpage when someone visits it.  Is there a cgi out there or someway to do this?
0
treyjeff
Asked:
treyjeff
1 Solution
 
cfrericksCommented:
you don't need to use cgi to do this.  A simple javascript will do this for you.  here it is:



<SCRIPT LANGUAGE="JavaScript">
var theurl = document.location
if (theurl == "put your page address here where you will use the midi randomizer") {
   
song = new Array(10);

song[0] ='m/first song title name.mid'
song[1] ='m/second song title name.mid'
song[2] ='m/third song title name.mid'
song[3] ='m/fourth song title name.mid'
song[4] ='m/fifth song title name.mid'
song[5] ='m/sixth song title name.mid'
song[6] ='m/seventh song title name.mid'
song[7] ='m/eighth song title name.mid'
song[8] ='m/ninth song title name.mid'
song[9] ='m/tenth song title name.mid'
song[10] = 'm/eleventh song title.mid'


index = Math.floor(Math.random() * song.length);document.write("<DL>\n");
document.write("<EMBED SRC="+song[index]+" width=200 height=55 autostart=true loop=infinite BGCOLOR='enter background color'");
document.write("</DL>\n");
}
else{}
</SCRIPT>

to add more songs to the randomizer change the song = new array to the appropriate number and duplicate the song [number] thing.
This script goes between the head tags of your homepage.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now