I'm new to using javascript in qualtrics. I am trying to implement a simple stopwatch on a survey item using this code https://learnwebsitedesign.com/tutorials/javascript-stopwatch-code-tutorial.php
It works for me in Visual Code Studio, when I source the javascrtipt code in my html file:
Javascript Source (making a stopwatch)
Best answer by JeremyK
Alright, I see what's going on. Qualtrics doesn't let you attach event listeners in the html like your guide is doing. When you copy in the html, Qualtrics is stripping the onClick functions when you exit. If you view the html again, you'll notice they're gone. This just means we need to add the onClick in the JavaScript, no big deal. Add these two onClick listeners to the bottom of your JS function underneath your increment() function and you should be golden. Tested and confirmed this works on a survey of my own making.
jQuery('#startPause').on("click", function() {
startPause();
});
jQuery('#reset').on("click", function() {
reset();
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.