getSelectedOptionsIndex

Description

This function will help you to get the indexes of the answer options selected for a question by the respondents and use it within your script.


Syntax

$survey.getSelectedOptionsIndex("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.getSelectedOptions("Q1");
        var items = ["Soccer","Cricket","Basketball","Hockey","Baseball","Tennis","Football","Badminton"];
        console.log(items);
        for (var i = 0; i < items.length; i++) {
        	if(!!~jQuery.inArray(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