I want to create a table with a row and a button (which plays a sound) in each row, and each button plays a different sound.
I want to do this with this method:
<script> function EvalSound(soundobj) { var thissound=document.getElementById(soundobj); thissound.Play(); } </script> <embed src="success.wav" autostart=false width=1 height=1 id="sound1" enablejavascript="true">
and this is the button:
<form> <input type="button" value="Play Sound" onClick="EvalSound('sound1')"> </form>
The problem is what I want here:
<input type="button" value="Play Sound" onClick="EvalSound('sound1')">
to write the url of the file instead of "sound1", can I do it this way? or do I need to change another code in the code?
Edit:
I will build the script as follows:
<script> function EvalSound(soundobj) { var embed = document.createElement('embed'); embed.setAttribute('width',1); embed.setAttribute('height',1); embed.setAttribute('src',soundobj); embed.setAttribute('autostart', false); embed.setAttribute('enablejavascript', true); embed.Play(); } </script>
and name it with:
<form> <input type="button" value="Play Sound" onClick="EvalSound('sound url')"> </form>
and it still does not reproduce sound.
source share