Simple Layout JS Disabling Forced Response | XM Community
Skip to main content

Hello!

I have a question, Q3, where if the user selects recode value 1, hide Q11 and auto-code Q11 = 7. The problem is, Q11 is a Forced Response and I'm having trouble disabling that. Does anyone know how to disable that with javascript? 

 

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/
    var qid11 = jQuery("#question-QID11");
    
    function checkAndToggle() {
        var selectedChoice = jQuery("inputename='QID3']:checked");
        if (selectedChoice.length > 0) {
            var choiceId = selectedChoice.attr('id');
            var recodeValue = choiceId.split('-').pop();
            
            if (recodeValue === '1') {
                qid11.hide(); // Hide when recode value is '1'
            } else {
                qid11.show(); // Show for all other values
            }
        } else {
            qid11.show(); // Show if nothing selected
        }
    }
    
    checkAndToggle();
    
    jQuery("inputname='QID3']").change(function() {
        checkAndToggle();
    });

});

 

Thanks in advance! 

Turns out you cannot disable “Forced Response” with JS. The workaround solution was applying custom validation to Q11 where:
 

Validation will pass if the following condition is met:

Q3 = 1Selected

Or

Q11 = 1Is Selected

Or Q11 = 2 Is Selected

Or Q11 = 3 Is Selected

Or Q11 = 4 Is Selected

Or Q11 = 5 Is Selected

Or Q11 = 6 Is Selected

Or Q11 = 7 Is Selected


You could also move Q11 to its block and skip it in the survey flow via branch logic.

Create an ED called Q11Value and set its value to either the provided answer or 7.


Leave a Reply