Online Survey Tutorials
SurveyGizmo Tutorials and Help Documentation
Tutorial: Scripting Sample: Exclude Option Selected in Previous Question
This series is dedicated to showing advanced functionality within SurveyGizmo using the Custom Scripting action (Pro plan or higher). While the tutorials are meant to be portable and easy to insert into your own survey, it will be necessary to understand advanced concepts such as Question IDs. These scripts are provided as-is without additional support for alterations.
This script uses the following question types or actions:
- A single select question (radio button or drop-down menu)
- Either a single select question or multi-select question (checkbox)
Description
This script will take the option selected in the first question and remove that option from the follow-up question on the following page that contains the same list of options. For example:
Q1 (radio button): What kind of pet do you have? 1) dog 2) cat 3) fish 4) bird 5) Iguana Q2 (checkbox): Did you avoid buying any animals because they are too messy, check all that apply? 1) dog (automatically remove this choice if selected in Q1) 2) cat (automatically remove this choice if selected in Q1) 3) fish (automatically remove this choice if selected in Q1) 4) bird (automatically remove this choice if selected in Q1) 5) Iguana (automatically remove this choice if selected in Q1)
The Script
%%sourceqid = 2; // single-select question id (radio,drop-down menu) %%targetqid = 3; // multi-select question id (checkbox) or single-select question id (radio, drop-down menu) /**** DO NOT ALTER BELOW THIS POINT ****/ %%value = sgapiGetValue(%%sourceqid); sgapiRemoveOption(%%targetqid,%%value);
The Steps
- Create your first question as a single-select question
- On a page following, add your second question
- On the same page as the second question, select Add Action > Custom Scripting Control and paste in the above code
- Alter the script for the proper question IDs
- Use the Reorder Questions option to place the Custom Script above the second question but on the same page
- Save all changes and test in preview mode
Warnings
The reporting values must be an exact match between the two questions.

