...

View Full Version : Pulldown Menu Choose MP3 Script



hominid4
09-03-2006, 05:39 PM
Hi, I'm just learning scripting and have no idea if I'm doing this correctly. I have a script where in a form I have a pulldown menu listing multiple MP3s, next to the pulldown is a "Play" button. When a MP3 is selected and Play is clicked it pops up a small window and plays the MP3. This works as I need it but the problem I'm having is if "None" is selected and "Play" is clicked I'm needing a small pop up saying "No sound selected.".

I thought it would be simple using a IF ELSE command but I can't get it to work. What I have in the head is:

function PlaySound(SongURL)

if (SongURL == "None")
{
alert("No sound selected.");
}
else
{
PopUp = window.open (SongURL, "width=200,height=30")
}
and in the body form I have:

<select name="music" onchange="javascript:formHandler()">
<option selected value="None">None</option>
<option value="01.mp3">01.mp3</option>
<option value="02.mp3">02.mp3</option>
<option value="03.mp3">03.mp3</option>
</select> <input onclick="PlaySound(music.options[music.selectedIndex].value)" type="button" value="Play" />
If I just have the below in the head it works:

function PlaySound(SongURL)
{
PopUp = window.open (SongURL, "width=200,height=30")
}
Could I please get some help on the IF ELSE, or if there's a different route I should take? Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum