setOptionSelected

Description

This function will help you to auto-select an answer option in a survey based on the previous selections made by the respondents.


Syntax

Single Select

$survey.setOptionSelected("Question Code","Option Index");

Multi Select

$survey.setOptionSelected("Question Code","Option Index Array");


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