- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>RailwayAnnouncement</title>
- </head>
- <body>
- <input id="TrainNumber" type="text" />
- <input id="Submit" type="button" value="Submit" onclick="submit();" />
- </body>
- </html>
- <script>
- function submit() {
- var TrainNumber = document.getElementById("TrainNumber").value;
- var length = TrainNumber.length;
- for (var counter = 0; counter <= length - 1; counter++)
- {
- var trackNumber = TrainNumber[counter];
- var audio = new Audio(trackNumber+'.mp3');
- audio.play();
- }
- }
- </script>
Here is what I did. Audio files are overlapping. But I want them to play one after another. Help me with suggestions.