getSelectedOption

Description

This function will help you to get the answer option selected by the respondents and use it within your script.


Syntax

$survey.getSelectedOption("Question Code")


Example Script

We can capture the options that are selected in the source questions(Q1) and by default select the same answer options under the follow up question.

arrow_rightScript

        var arr = $survey.getSelectedOption("Q1");
        var items = ["Soccer","Cricket","Basketball","Hockey","Baseball","Tennis","Football","Badminton"];
        //console.log(items);
        for (var i = 0; i < items.length; i++) {
        	if(items[i] == arr) {
        		//console.log(items[i]);
            $survey.setOptionSelected("Q2", i+1);
        	}
        }

                   

Example Survey: Survey Link


Supported Question Types

  • Multiple Choice: Select One
  • Multiple Choice: Select Many
  • Multiple Choice: Drop Down
  • Basic Matrix: Multi-Point Scales
  • Basic Matrix: Checkbox/Multi-Select
  • Image Chooser: Select One
  • Image Chooser: Select Many
  • Image Chooser: Select Rating
  • Graphical Rating: Thumbs Up/Down
  • Graphical Rating: Smiley - Rating
  • Graphical Rating: Text Slider
  • Graphical Rating: Numeric Slider
  • Customer Satisfaction: Net Promoter Score
  • Data Reference: Lookup Table

Need help? Contact Us