I've been doing online research for the past few weeks and have come across similar solutions to what I'm trying to achieve. However, due to my limited knowledge of javascript, I am struggling to implement them effectively.
My goal is to have an audio tag that plays a different audio file depending on the day of the month. Essentially, when clicking play, the corresponding file for that specific day should be played using the audio player.
Below is my current audio tag:
<audio preload="metadata" controls="controls" src="" id="todays" autoplay="none"></audio>
This is the JavaScript code I'm using:
function todaywm() {
var a, dayofmonth
a = new Date()
dayofmonth = a.getDate()
document.getElementById('todays').src = radiolinks[dayofmonth]
}
var radiolinks = new Array(31)
radiolinks[1] = "audio/day01.mp3"
radiolinks[2] = "audio/day02.mp3"
radiolinks[3] = "audio/day03.mp3"
// etc...
radiolinks[29] = "audio/day29.mp3"
radiolinks[30] = "audio/day30.mp3"
radiolinks[31] = "audio/day31.mp3"
Despite my efforts, I have not been successful in making it work as intended. I'm still relatively new to javascript and learning as I go.