Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Branching with free format

Hi ... I have a question in free format asking for feet and inches.  I'm branching off a select question to show it.   Here's the code:

                        {
                        dependentQuestion: 'S5metric',
                        condition: function() {
                            return SSI_GetValue('S5units') == 1;
                        },
                            {
                        dependentQuestion: 'S5imperial_feet',
                        condition: function() {
                            return SSI_GetValue('S5units') == 2;
                        },
                            {
                        dependentQuestion: 'S5imperial_inches',
                        condition: function() {
                            return SSI_GetValue('S5units') == 2;
                        }    


If I take the freeformat bit out, the metric (numeric) question works fine.
 With the freeformat bit in, none of the branching works.  Everything is visible on load.  What stupid thing am I doing?
asked Dec 9, 2020 by Marion Bronze (4,460 points)

1 Answer

+1 vote
Currently, Branching doesn't know how to show or hide specific input fields - it only applies to whole questions.  For what you're after, it sounds like you ought to remove the third branching rule and update the second one to apply to "S5imperial" rather than "S5imperial_feet."
answered Dec 9, 2020 by Zachary Platinum Sawtooth Software, Inc. (171,950 points)
When I do that, none of the branching works at all - not even the S5metric.  Everything is visible.
And I should have mentioned that each has a Not Applicable assigned.  Although when I removed those to test behaviour, it didn't make any difference.
Oh, you've also got mismatched braces.  I'd make the "branchings" area look like this:

    branchings: [
        {
            dependentQuestion: 'S5metric',
            condition: function() {
                return SSI_GetValue('S5units') == 1;
            }
        },
        {
            dependentQuestion: 'S5imperial',
            condition: function() {
                return SSI_GetValue('S5units') == 2;
            }
        }
    ],
A thing of beauty!  Thanks!
...