New to JS/not very experienced in qualtrics and struggling to figure this out. Respondents answer a question regarding a likelihood (i.e., enter a number from 0 to 100) and I want to ask them how confident they are that the right answer is between their answer +/- 5%. I can compute these values with embedded data, e.g.,
Up_10yr_plus5=$e{ ${q://QID4/ChoiceTextEntryValue} + 5}.
My problem is if someone answers, for example, 97, I would like the variable up_10yr_plus5 to be 100 rather than 102 (97+5).
From what I’ve read, it seems I need to use javascript (as math functions in embedded data are limited) to write something like:
Qualtrics.SurveyEngine.addOnload(function()
{
var max = Math.max("${e://Field/Up_10yr_plus5}",100);
Qualtrics.SurveyEngine.setEmbeddedData("max", max);
});
I thought that this would create a new embedded variable called max that I could then insert in my question. Yet, when I select insert piped text, embedded data field, Up_10yr_plus5 shows up but max does not.
Any guidance would be appreciated.