RRTG
RRTG

Reputation: 35

Counting Number of Text Entry Answers on Qualtrics Survey

I am entirely new to both Qualtrics and Javascript (as such, apologies for how elementary this question may be). I have a survey on the former that will require using Javascript in a couple of the different Blocks in the survey to count the number of answers provided by a user in a number of different text entry boxes (all of which are in just one Block).

We want to pay respondents by the number of suggestions they make, so I really just want to count how many of the different text entry boxes in that one question Block have something written in them, to then use as a variable in another Block at the end of the survey to pay respondents based on how many questions they answered.

Conceptually, I assume it'll just mean initializing a counter, looping over the N text entry boxes we have, adding +1 to the counter for every one of those N boxes in which anything has been entered (I'm not worrying about whether what is entered is actually meaningful to us, assuming people don't just enter spaces), and keeping that variable to use in the very last block of the survey (where we tell them what they have earned, which is a fixed amount per suggestion). I just can't seem to find even the building blocks/ elementary syntax to implement that very simple counter through Googling and searching around here (I tried to get a bit of inspiration from these questions but no success so far: (1) Qualtrics Word Counter Javascript; (2) Qualtrics: javascript - text entry).

Any help would be appreciated!

Upvotes: 0

Views: 693

Answers (1)

T. Gibbons
T. Gibbons

Reputation: 5004

You can do this in your survey flow after the text entry questions block:

Embedded Data: count = 0
Branch: If Text Question 1 Not Empty
  Embedded Data: count = $e{ e://Field/count + 1 }
Branch: If Text Question 2 Not Empty
  Embedded Data: count = $e{ e://Field/count + 1 }
etc...

At the end count will equal the number of text entry questions answered.

Upvotes: 0

Related Questions