Piping: Radio Button Grid Into Checkbox Question

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!

Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.

In this example is a script which queries for which rows in a Radio Button Grid respondents answered an option between the values of 6 and 10 and then filter the list of options in the subsequent Checkbox question accordingly. For this to work the target question must be setup with answer options included in the source question table row titles and automatic piping turned off.

Note: This script will work with conditional piping from a Radio Button Grid question into any question with a list of answer options (i.e. Textbox List, Radio Button, Checkbox, Multi-Slider, Dropdown Menu, etc.) 

Example survey (5th - 6th page): http://www.surveygizmo.com/s3/2055700/Custom-Piping-Filtering


Want to download this survey to your account so you can play with it? Just click here.

Estimated implementation and testing time: 5-10 minutes

This script uses the following custom scripting functions:

  • sgapiGetValue
  • sgapiGetQuestionOptions
  • sgapiRemoveOption
  • sgapiCount
  • sgapiJumpToPage

The Script

The script below requires the for us to plugin the question ids of the source Radio Buttons Grid question, the target question, the id of the next page to jump to (should there be nothing to display on the page with the target question), and optionally a value of true or false depending on if you have an exclsuive 'Not Applicable' / 'None of the Above' type option in your target Checkbox question. 

%%source_id = 3; //radiotable id
%%target_id = 22; //checkbox q id
%%na_present = true; // set this to true if there is a not applicable type option in the checkbox list and false if not
%%next_page_id = 8;

%%table = sgapiGetTableQuestionTitles(%%source_id); //id => title
%%checkboxes = sgapiGetQuestionOptions(%%target_id);

%%hidden_options = 0;
foreach(%%table as %%id => %%title) {
   %%value = sgapiGetValue(%%id);
   if(!((%%value >= 6) && (%%value <= 10))) {  //if the answer is not between 6 and 10

      sgapiRemoveOption(%%target_id, %%title);
      %%hidden_options += 1;


if(((sgapiCount(%%checkboxes) == %%hidden_options) && (%%na_present === false)) ||
(((sgapiCount(%%checkboxes) - 1) == %%hidden_options) && (%%na_present === true))) {



In the script above you will need to customize variables highlighted in yellow in order to make the script work the way you'd like.

Required Customizations

%%source_id - This variable will indicate the question ID of the source Radio Button Grid question.

%%target_id - This variable will indicate the question ID of the target Checkbox list / any list of answers type question.

%%na_present - Set to 'true' if you have an exclusive answer option  (like 'None of the above', etc) which you would like to appear in the target Checkbox question irrespective of what is chosen in the source question.

%%next_page_id - The page to jump to if no options are selected in the source question which correspond with answer options in the target question.

Scripting and Other Custom Solutions

We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.

If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your customization. Beyond this, you might want to consult with someone on our Programming Services Team; these folks might have the scripting chops to help you to achieve what you are looking for!