I want to create a table with string and button(that play sound) in each row and every button play a different sound.
i want to do it 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 that i want here :
<input type="button" value="Play Sound" onClick="EvalSound('sound1')">
to write the file URL instead of ‘sound1’, it is possible to do it in this way? or i need to change another stuff in the code?
Edit :
i build the script like this:
<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 call this with :
<form>
<input type="button" value="Play Sound" onClick="EvalSound('sound url')">
</form>
and it still not play the sound.
You can achieve it as follow:
refer blog How to Play a Sound on Click or on MouseOver
In web page