Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

How to set a default choice based on Variable Name?

filipe
filipe lisbonCommunity Member - Trial User Qubie ✭
edited December 2018 in Custom Code

Hi!!!

Basically I want to set a default choice based on the answer given in the previous question and to do so I'm using the following JavaScript

However, this is not working. Actually, it is setting the choice based on the recorde Value instead on the Variable Name.

Can anyone help me out with this?

Thanks

Best Answer

  • PraDeepKotian_Ugam
    PraDeepKotian_Ugam Mumbai, IndiaCommunity Member, Qualtrics Brand Admin Superuser ✭✭✭✭
    edited December 2018 Accepted Answer

    Hello @filipe ,

    Below is the code for setting the default choice based on the answer given in the previous question

    var val  ="${q://QID30/ChoiceGroup/SelectedChoices}".split(", ");    
            for (var i = 0; i < val.length; i++) { 
                this.setChoiceValueByVariableName(val[i],true);
            }
    

Answers

  • Kate
    Kate Community Member, Qualtrics Brand Admin Wizard ✭✭✭✭✭
    edited December 2018

    You're pulling in the piping for the recode... did you try just ${q://QID30/ChoiceGroup/SelectedChoices}?

  • filipe
    filipe lisbonCommunity Member - Trial User Qubie ✭

    @Kate said:
    You're pulling in the piping for the recode... did you try just ${q://QID30/ChoiceGroup/SelectedChoices}?

    Thanks for your reply Kate.

    It doesn't work. I did that and it doesnt set any default choice.
    As I have it now, it sets a default choice based on the Recorde Value. But what I want is based on the Variable Naming

    The "Variable Naming" of this question:

    should match the variable name of this question:

  • filipe
    filipe lisbonCommunity Member - Trial User Qubie ✭

    Thanks for the answer @PraDeepKotian_Ugam but is not working :(