Have an idea?

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

Using the Not Applicable question on two numeric questions

I have two numeric questions on the same survey page and would like to add the Not Applicable question to that page.

The current Not Applicable question currently works nicely for one numeric question but not this scenario.

Ticking the check box will need to clear both numeric questions.

Both numeric questions must be answered or the check box.

asked Sep 13, 2018 by Paul Moon Platinum (101,255 points)

1 Answer

0 votes
Best answer
Custom verification for the numeric questions:

var notApplicableQuestion = 'SelectQ';

if ($('#[% QuestionName() %]').val() === '' && !SSI_GetValue(notApplicableQuestion + '_1')) {
    strErrorMessage = 'Question must be answered or "Not Applicable" must be checked.';

JavaScript for the select question:


function SSI_CustomGraphicalCheckbox() {
    var numericQ1 = 'NumericQ1';
    var numericQ2 = 'NumericQ2';
    var numerics = $('#' + numericQ1 + ',#' + numericQ2);
    if (SSI_GetValue('[% QuestionName() %]_1')) {
        $(numerics).prop('disabled', true);
    else {
        $(numerics).prop('disabled', false);

Replace "SelectQ," "NumericQ1," and "NumericQ2" with the names of the select question and two numeric questions, respectively.
answered Sep 13, 2018 by Zachary Platinum Sawtooth Software, Inc. (214,575 points)
selected Sep 13, 2018 by Paul Moon
Thanks a million for responding so promptly Zachary.

I've had a first trial on it and almost have it working entirely.

Both numeric boxes are clearing when the check box is ticked.

Both numeric boxes can be answered and the check box unticked and I can proceed forward.

The check box can be ticked without answering the numeric questions.

The only problem I am seeing is I can proceed forward without answering anything?

Both numeric questions must be answered OR the check box ticked.

Is there an issue with the JavaScript at the numeric questions?

I changed SelectQ to S2x (check box question) and placed this script into both numeric questions.

That should already be the behavior of the code.  Can you post your codes post-updating them?  Are there any errors that appear in your browser's console when you open this page or when submitting the page?
I sent you an email with the ssi file and snapshot of the browsers console. I did spot an error for S2x?
You do not need any of the original Not Applicable code for this.  The code above alone should do the trick.
OK, got it.

Sorry for the mix up.

I thought I had to add it to the original script.

I have removed the Not Applicable JavaScript from the verification window and the script in the footer.

Works now. Awesome!

I hope others find this useful too.

Thanks again mate. You're a ripper (Aussie for really good / excellent)!
I could have done it starting from the original code.  The problem comes from the error highlighting code, specifically the red box that appears around questions that have an error.  The original NA question puts the checkbox in the main question so that the highlighting nicely surrounds both the question and the checkbox.  With two questions coming before the checkbox, the red box will only appear around the second question even though the checkbox applies to both questions.  I feel like this is going to trip up respondents who don't realize that a question outside of the box is the one that needs to be answered.

If I were to change Not Applicable to formally support multiple questions, I would probably get rid of the default red boxes on the page and re-implement them myself so I could get the highlighting right.
Go it thanks Zachary.

I noticed when I had both codes in there, the red error box had disappeared.

Again, appreciate the effort of providing a neat solution.

This would be helpful to others I'm sure.