Script API Tutorial

Skipping question based on numeric answer in «Open-ended» question

Suppose that we have a question where we ask a Respondent how many credit cards he/she has. In the next question we ask the Respondent how often he/she uses those credit cards.

Of course, if the Respondent doesn’t have any cards, there is no sense in asking second question. So, we can hide the second question depending on the answer to the first one.

See how it works:

Give it a try

In order to reproduce this example, please undertake the following steps:

Open Questionnaire editor and add an "Open Ended" question (one alternative is enough for demonstration), then select "Numeric" checkbox as shown in the image below

Create a "Single Answer" question and ask something related to your "Open Ended" question.

After that come back to the first question, open Script Editor and insert the following script into "OnNextPage script" tab (see the image below).

  • if (this.get()[0].value =='compVar')
  • q['QuestCode'].hide();

After that modify the tokens highlighted in red as described in the table below:

compVar Condition for hiding the second question. If Respondent’s answer equals this condition, the next question will be hidden. In our example this value should be "0" meaning that the Respondent has no credit cards.
QuestCode Code of our "Single Answer" question

Learn more at CoolTool knowledge base

Accessing Survey Items