Play audio using an input button

I'm trying to play audio when a user clicks on a button. I'm passing the sound file to a function. The question is programmed using free format.

The audio file is defined in the HTML tag as follows:


<embed src="../graphics/sound/audio1.mp3" width=0 height=0 name="soundfile" >


Here is the code for the button defined in the body of the HTML.

<input type="button" name="apb" value="Play Audio" onClick="EvalSound('sound1')">


Here is my function code located in the HTML <head> tag section:

<script>
function EvalSound(soundobj) {

var thissound = document.getElementById(soundobj);

thissound.Play();

}
</script>

Resolved
2 replies