Reputation: 15
how do I pass play_ID into the the function toggleSound()?
onclick=\"javascript:var play_ID=$id;toggleSound();\"
<script type=\"text/javascript\">
<script type=\"text/javascript\">
function toggleSound() {
audioElem = document.getElementById(\"audio". $row["ID"]."\");
if (audioElem.paused)
audioElem.play();
else
audioElem.pause();
}
</script>
Upvotes: 0
Views: 72
Reputation: 621
If I understand you question correctly, you want to pass the $Id variable into your function?
onclick=\"javascript:toggleSound($id);\"
<script type=\"text/javascript\">
<script type=\"text/javascript\">
function toggleSound(inVar) {
//inVar is equal to the variable you want to pass into the function.
audioElem = document.getElementById(inVar);
if (audioElem.paused)
audioElem.play();
else
audioElem.pause();
}
</script>
Upvotes: 2