Friday, September 14, 2018

SurveyGizmo Checkbox Options Selected

SurveyGizmo custom script has a function (sgapiGetQuestionOptionSelected) to return the selected option for a single or multiple select question. For a single select question it always returns a single number. Unfortunately for a multiple select question the return value depends on the number of options selected. If multiple items are selected an array is returned but if only one item is selected just that option's id is returned. Makes it harder to write code to check if certain items were checked.

So I wrote the following function to always return an array regardless of the number of items selected.