I seem to have a quite simple question, but fail to make it work. I want to include a timer that only starts when clicking (a button or into the text-box) and not already when entering the page.
This is basically the same question, which sadly failed to provide an answer to the question. https://community.qualtrics.com/XMcommunity/discussion/15059/timer
I tried some code from StackOverflow, but I am also not able to make it work: https://stackoverflow.com/questions/52916798/start-timer-on-button-click-not-working-javascript
Any help would be immensely helpful!
Best wishes,
Felix
Hi there, I followed the "Adding a Timer that Spans Pages" section in the below article and adapted it so that it only triggers when a question is clicked into and it is specific to the question the code is added to.
https://medium.com/@mc_bloomfield/javascript-and-qualtrics-getting-started-34f113cbeaaa
In the attached QSF, I have put together question specific timers for Multiple Choice and Text Entry questions. There are things that can be adjusted, such as what happens when the timer reaches 0, but hopefully this should get you going in the right direction.
QuestionSpecificTimer.qsf
That is already a great start!! I tried to dive into it, but run on two main issues:
- The timer is running, even when it is not shown. If I wait 30 seconds before I click something, the timer starts with 30 seconds less. I fail to find how I could adapt this, so that it will always start after the first click but always at e.g. 2 minutes.
- As soon as I edit the question text, the timer disappears. Everything works fine with the "Basic template" you have sent. However, as soon as I input my question text the timer disappears.
Hi, great catch on number 1! The "Start" time was being set on page load, but I have updated it so that it isn't set until the question is interacted with. You might need to tweak the JS depending on the question input type, but it's working for me for MC and Text Entry in this updated QSF:
QuestionSpecificTimerV2.qsfThe JavaScript for the Timer can be edited by clicking on the ">" icon in the top right of the question within the Survey Builder. For editing the Question Text, you'll want to do that through the Rich Content Editor. You might even want to use the Source View "<>" in the Rich Content Editor to input the question text to ensure you don't alter the Timer's HTML.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.