Multiple Choice Button to Play Hidden Audio | XM Community
Skip to main content
Question

Multiple Choice Button to Play Hidden Audio

  • April 20, 2023
  • 3 replies
  • 125 views

Forum|alt.badge.img+3

hello, 

 

I would like to have a multiple-choice option play a hidden audio file. Does anyone know how to do that? I know how to hide the audio but don’t know how to have the selection of the choice trigger the audio to play. 

 

Thank you! 

3 replies

Forum|alt.badge.img+15
  • QPN Level 4 ●●●●
  • April 20, 2023

Hi @AnnaM89 ,

 

I think you can refer to this video link on how to hide and play around with audio file. 

Instead of Image click, just change the javascript code to “label” or “id” on which you want to play audio.

Hope this helps.

 

Thanks,

JB   


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • April 21, 2023

Thank you for this! Having a click on an image to trigger would be fine. However, I am getting an error with the code suggested in the video: 

 

Qualtrics.SurveyEngine.addOnload(function()
{
    
});

Qualtrics.SurveyEngine.addOnReady(function(){
    
    jQuery(".img").on('click',function)(){
        
        jQuery('audio').trigger("play");
        
    });
    
});

Qualtrics.SurveyEngine.addOnUnload(function()
                                   {
    
});

 

Can you see anything wrong with it? Sorry - I am not very familiar with javascritpt. 

 

Thanks again! 


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • April 24, 2023

Hello again, 

 

I was able to get this working. However, when I have multiple audio files - it plays all of them. How can I specify it to only play one per image? 

 

Thanks!