Hide a choice, select it through JS and give it a score | XM Community
Skip to main content
Question

Hide a choice, select it through JS and give it a score

  • 6 August 2019
  • 2 replies
  • 23 views

Hello everyone,



Is it possible to add a choice button that is invisible and that is always selected if choice Yes=1 is selected?

Additionally, I need to assign a score to that invisible button, that is counted if it is activated?



So basically, can I make the button disappear, but

(1) still select it through javascript?

(2) still give it a score beforehand?



Thank you,

Liss



!
Why not just assign the score to Yes?



Anyway, you could do it, but your question would have to be a multi-select with No exclusive. Then, hide the third choice with JS.

```

jQuery("#"+this.questionId+" li.Selection").eq(2).hide();

```
You are right, I thought too complicated. But I can't make the code work. Maybe you can help me with it?



If t ${e://Field/Correction_score} == "${gr://SC_cACxBQtCmaZwCln/Score}",

set the initial_choice =choice

if not, set the correctedchoice = choice.



The choice can be 1 or 0. The important thing is that he doesn't overwrite the other choice.

e.g. EDScore and Score are equal and the choice is 1=yes: initial_choice becomes 1 nothing happens to correctedchoice.

EDScore and Score are unequal and the choice changes to 0=no: correctedchoice becomes 1 and initial_choice stays 0.



Qualtrics.SurveyEngine.addOnPageSubmit(function() {



var selectedRecode = this.getChoiceRecodeValue(this.getSelectedChoices());

var choice = (selectedRecode == 1) ? 1 : 0;

Qualtrics.SurveyEngine.setEmbeddedData("Choice", choice);



var correctedchoice = [];

var initial_choice = [];



if ( parseInt("${e://Field/Correction_score}") == ("${gr://SC_cACxBQtCmaZwCln/Score}")) {

initial_choice = choice;

} else {

correctedchoice = choice;

};



Qualtrics.SurveyEngine.setEmbeddedData("Initial_choice", initial_choice);

Qualtrics.SurveyEngine.setEmbeddedData("Correctedchoice", correctedchoice);

Leave a Reply