Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

HTML Play button coding

  • GrantLab
  • GrantLab's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 7 months ago #173547 by GrantLab
HTML Play button coding was created by GrantLab
I am attempting to code in a one-press play button for a survey (so that participants can play a song but not pause it during listening). I had it working in Qualtrics previously using the following code:

<audio id="audio1" src=" qeurope.eu.qualtrics.com/CP/File.php?F=F_9B0gZSCUL1iV6Cx ">
<div>
<button onclick="document.getElementById('audio1').play()">Play</button>
</div>

I have altered the code in LimeSurvey as such:

<audio id="audio1" src=" mtroyalpsych.limequery.com/upload/survey...nt_Stop_Believin.mp3 " type="audio/mpeg"> 

<div><button onclick="document.getElementById('audio1').play()">Play</button></div>

My issue is that the Play button will display but it won't play the song when clicked. Instead it refreshes the current question when I test it in Survey preview. Anyone see what is wrong with the coding here? I'm a major newbie with HTML.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #173567 by tpartner
Replied by tpartner on topic HTML Play button coding
Add a type="button" attribute. This should prevent the button from submitting the form.
Code:
<button type="button" onclick="document.getElementById('audio1').play()">Play</button>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose