Hi, I want to set a variable. If people click one button within 10 seconds, we display some questions and ask people to click next button to proceed. If people don't click the button within 10 seconds, will automatically click the next button and go to next block. The question is I don't know how to define and use a global variable. In the following js, x_val is set to 1 within the block but after 10 seconds, the next function still works, it takes x_val as 0 and automatically proceeds to next block, which leads to even if people leave this block, it automatically jumps to the third block when people in the second block. How can i solve this, thanks!!
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("#NextButton").hide();
var x_val=0; // set this variable equal to 0.
jQuery('#Button').on('click', () => {
x_val=1; // set this variable equal to 1
jQuery("#NextButton").show();
});
// after ten seconds, if button is not clicked, automatically click next button
setTimeout(function(){
if (x_val==0){
jQuery("#NextButton").click();
}
}, 10000);
}, 30000);
});
How to set a variable and use it in different functions
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.
