Cascading Dropdown: Select Option When Only One is Present

If you are using the Cascading Dropdown question and one of your menus has only one option you might want to have the survey automatically select it for your respondents. While there isn't a built-in way to achieve this; we have a super-simple, copy-and-paste script that will do this for you.

Check it out in an example survey!

OR

Add a survey with this script to your account!

Setup

  1. To set this up add a JavaScript Action to the same page as your Cascading Dropdown question.
  2. Copy and paste the below script. Save your JavaScript Action and test it out!

$(function() {
    $('.sg-question-cascading select').change(function() {
        var el = $(this);
        if (el.children().length == 2 && el[0].selectedIndex != 1) {
            el[0].selectedIndex = 1;
            el.trigger('change');
        }
    });
});

Note: If you have multiple Cascading Dropdown questions in your survey with a single option in one of the dropdown menus, you will need to add this script to each page where the a Cascading Dropdown is present.

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 Alchemer features and functionality ideas that might meet your needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In