Invisible Question | XM Community
Skip to main content

Hi, 

 

I need help making a multi-choice question invisible. I have added a single choice multi-choice question in which the answer is selected when the user hits a Withdraw From Survey button in the footer to withdraw and go straight to the debrief. This all works fine, however I have tried JS code from other posts on this forum and cannot get my multi-choice question to become invisible - the question is just a blank space but the radio button is still visible and highlights blue when the withdraw button is used. 

 

Here is the current working JS Im using in the question. EndNow is the name of my withdraw button:

 

Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
var endBtn = document.getElementById("EndNow");
function skip() {
that.setChoiceValue(1, true);
that.clickNextButton();
};
endBtn.addEventListener("click", skip);
});

You need to revise code as below:

 

Qualtrics.SurveyEngine.addOnReady(function() {
    var that = this;
    var endBtn = document.getElementById("EndNow");

    // Function to hide the question
    function hideQuestion() {
        var questionContainer = document.getElementById(""+that.getQuestionContainer().id);
        questionContainer.style.display = "none"; // Hide the entire question container
    }

    // Function to set choice value and navigate to the next question
    function skip() {
        that.setChoiceValue(1, true); // Select the first choice
        hideQuestion(); // Hide the question
        that.clickNextButton(); // Go to the next question
    }

    endBtn.addEventListener("click", skip); // Attach the skip function to the EndNow button
});


Leave a Reply