Why my functions cannot work? | XM Community
Skip to main content
Question

Why my functions cannot work?


I'm new to javasript programming, so I have no idea why my code cannot work properly on qualtrics. This code aims to conduct a simple research. The participants need to click the "add" button to add red balls into the box, and if they want to draw a ball from the box, they should click the "draw button". If the participants pick a red ball, they win the game.
When I ran the code attached below, the console showed that my functions were not defined. Would you please give me some advices? Thanks a lot!
Javacript code:



Welcome to the game!









https://mays.ca1.qualtrics.com/ControlPanel/Graphic.php?IM=IM_3CoVCiGYSBcYWhL" width="320" height="240">













2 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • 1448 replies
  • August 23, 2020

On just going through the code, one mistake we can see is that - 'document.write' function is disabled in qualtrics. So instead of that, you can use some p tag with id to display the text.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5891 replies
  • August 23, 2020

Also, don't put JavaScript in the question text. Click "Add JavaScript..." and add your JavaScript there. Put the JS inside the addOnload function.


Leave a Reply