Monday, 1 October 2018

select plus option dropdown list to play audio files

I would like to use a select plus option dropdown list to play audio files. I'd like to avoid using a submit button in favor of just using javascript onmouseup. The code below should work, but just displays the dropdown list and audio controls. Can someone please help?

<form onsubmit="return false;">

<select id="audio_select">
<option value="Happy_Birthday">Song #1</option>
<option value="My_Way">Song #2</option>
<option value="Satisfaction">Song #3</option>
</select> 
<button onmouseover="submitted_audio()">Submit</button>
</form>

<script>
function submitted_audio(){
link = document.getElementById("audio_select").value;
document.getElementById("audio_player").src = "audio/"+link+".ogg";
}
</script>

<audio controls><source id = "audio_player" type = "audio/ogg"></audio>



from select plus option dropdown list to play audio files

No comments:

Post a Comment