Hello,
I am trying to delay the amount of time that the answer choice is selected. If a person spends more than, say 3000 milliseconds trying to answer the question, then it will automatically select the first answer choice.
Here's what I have:
setTimeout(function() {
jQuery("#"+this.questionId+" select option:eq(1)").prop("selected",true);
}, 3000);
The code within the function works fine on its own (if it's not in the setTimeout function), but doesn't get executed if it's put in the function once those 3 seconds are up. I also know it's not an issue with the function itself, because when I add an alert in there, the alert goes off after 3 seconds.
More info: that first choice which is automatically selected is hidden from the survey respondent. I used a lot of the code from this post to implement my overall solution. Let me know if I should post more of my code to help with the debugging.
Any help is appreciated, thanks a lot! 😀
SetTimeout Function not executing code
Best answer by ahmedA
thisrefers to the context of the specific function being executed, so
this.questionIdwill return and error/null. Either store the value of
this.questionIdinto a variable. Or define
that = thisbefore the setTimeout method and then use
that.questionId
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
