Have an idea?

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

Use autonext on "none of the above" in multiple choice questions

Hi,

I am trying to add autonext for my "none of the above" alternative in a checkbox question, but I can't seem to get it to work.

Q10_9 is the last alternative, and the "none of the above" which I need autonext on.


<script>
       function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj)
       {
             if (InputObj.name  == "Q10_9" )
             {
                    SSI_SubmitMe();
             }
       }
</script>


Any tips?
asked Jan 17 by Ingvild (170 points)

1 Answer

+1 vote
You've got a great start.  This would work if not for some quirkiness in the JavaScript.

The problem is that exclusivity goes both ways.  Every time a respondent checks an exclusive checkbox, the JavaScript goes through and unchecks the other checkboxes.  And every time a respondent checks a non-exclusive checkbox, the JavaScript goes through and unchecks any exclusive checkboxes.  SSI_CustomGraphicalCheckbox is triggered by both clicks from respondents and these automatic unchecks (even if the box was already unchecked).

We can get around this quirk by capitalizing on SSI_CustomGraphicalCheckbox's third parameter, to ensure that SSI_SubmitMe is not fired during uncheck actions:

<script>
function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj, bln)
{
    if (InputObj.name == "Q10_9" && bln)
    {
        SSI_SubmitMe();
    }
}
</script>


This gets us closer, but there's still one more problem.  If a respondent checks this checkbox, our SSI_CustomGraphicalCheckbox code will run before the code that automatically unchecks the other checkboxes.  The SSI_SubmitMe will try to submit the page too early.

To get around this, we need to make the script uncheck the other boxes itself before triggering SSI_SubmitMe so we can know that the page is good to go.  Try this out:

<script>
function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj, bln)
{
    if (InputObj.name == "Q10_9" && bln)
    {
        for (var i = 1; i <= 8; i++) {
            SSI_SetSelect("Q10_" + i, false);
        }
        SSI_SubmitMe();
    }
}
</script>
answered Jan 18 by Zachary Platinum Sawtooth Software, Inc. (121,525 points)
...