Hi there im trying to modify my php code to add a javaa script link that plays an audio file. The java script works fine with just html:
<script type="text/javascript">
var channel_max = 10; // number of channels
audiochannels = new Array();
for (a=0;a<channel_max;a++) { // prepare the channels
audiochannels[a] = new Array();
audiochannels[a]['channel'] = new Audio(); // create a new audio object
audiochannels[a]['finished'] = -1; // expected end time for this channel
}
function play_multi_sound(s) {
for (a=0;a<audiochannels.length;a++) {
thistime = new Date();
if (audiochannels[a]['finished'] < thistime.getTime()) { // is this channel finished?
audiochannels[a]['finished'] = thistime.getTime() + document.getElementById(s).duration*1000;
audiochannels[a]['channel'].src = document.getElementById(s).src;
audiochannels[a]['channel'].load();
audiochannels[a]['channel'].play();
break;
}
}
}
</script>
<audio id="multiaudio1" src="Music/reb.wav" preload="auto"></audio>
<audio id="multiaudio2" src="Music/emp.wav" preload="auto"></audio>
<a href="javascript:play_multi_sound('multiaudio1');">audio1</a><br />
<a href="javascript:play_multi_sound('multiaudio2');">audio2</a><br />
But when i modify my php hyperlink:
echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].'"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>';
to:
echo '<a href="http://localhost/swb/fleet.php?recordID='.$row_Fleet['FleetName'].'" onclick="play_multi_sound(\'multiaudio1\');"> <IMG SRC="',$pic1,'" WIDTH="12" HEIGHT="10" BORDER="0" ALT="" CLASS="fmoncalamari"></a>';
then the hyperlink and parsed id works fine but the audio doesnt at all?
Any ideas?
Thank you 🙂