In my survey, first I set a couple of Embedded Data for testing, MondayAM and MondayPM:
I have then a simple matrix in Question 1 that accepts numeric values only (see screenshot):
E.g. 'Monday - AM' can be either 0 or anything <> 0
I added the following Java code in Question 1:
Qualtrics.SurveyEngine.addOnload(function()
{
if
("${q://QID1/ChoiceNumericEntryValue/1/1}" == "0")
{Qualtrics.SurveyEngine.setEmbeddedData("MondayAM", 0)}
else if
("${q://QID1/ChoiceNumericEntryValue/1/1}" != "0")
{Qualtrics.SurveyEngine.setEmbeddedData("MondayAM", 4)}
});
In Question 2, field ${e://Field/MondayAM} should display 0 when the q://QID1/ChoiceNumericEntryValue/1/1 value is 0, 4 otherwise.
Guess what? It does exactly the opposite; it returns 4 when 0 or no values are entered (default 0), 0 when I entered a value (e.g. 11).
The ultimate goal is to have the total hours by week, adding 4 hours for each slot populated by values <> 0.
What am I doing wrong?
Thanks.
If/else condition somehow works, but it returns exactly the opposite of what I want (!!!)
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

I added the code to Question 2:
... and I get the error when I Save it:
I need a vacation! 😁
Is it maybe possible that it calculates the values in the Total column as well?