How to leave page automatically after third click in matrix question? | XM Community
Skip to main content

Hey, I am constructing an attention task game where the respondents have to choose three elements in a matrix question. I would like to implement that they leave this page automatically after the, e.g., third or fourth click. Unfortunately, I do not know how to tackle this problem using JS.
I would be very glad if anyone has an idea!

Hey Quavid!
I modified a click function I use in some of my surveys, hope this gets you what you need!
Qualtrics.SurveyEngine.addOnload(function () {
    var that = this
    var counter = 1;

    jQuery('tbody').find("input'type='checkbox']").on("click", function () {
        console.log("counter: " + counter);
        if(!(counter >= 3)) {
            counter = ++counter;
        } else {
            that.clickNextButton();
        }
    })
});


There's a few things I don't love about this solution, but it should get you 90% of the way there. It's currently configured as a hard cutoff at 3 clicks (before the Next Button is clicked), but you mentioned possibly wanting 4 clicks and I could tailor it to be a function that takes a variable of counter and you could pass it the max number of clicks you want to grant your gamers. Another thing I didn't like was this code counts unchecking as a click as well and I foresee that giving you some trouble down the road. Again, let me know and I can modify the code for you.


Leave a Reply