Have an idea?

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

Add two different Not Applicable Questions on the same page

Hello,

I am a new user of Sawtooth and I found the Not Applicable Question in the library.

I would like to know if it is possible to add two of these questions in the same page. For example:

Page 1
Question 1 (numeric): ask about height and add the Not Applicable Question

Question 2 (numeric: ask about weight and add another Not Applicable Question

I tried the example but I am not able to see the checkbox of the second Not Applicable Question.

Thanks
asked Dec 18, 2019 by anonymous

1 Answer

+3 votes
I needed the same functionality and Zach provided this script.  Replace the script in the footer of the Not Applicable questions with this and it should work as desired.

<style>
#[% QuestionName() %]_div {
    display: none;
}

.error_quest_highlight2 {
    border: 1px solid red !important;
}
</style>

<script>
$(window).on('load', function(){
    // Question
    var question = $('#[% QuestionName() %]_div').prevAll('.question')[0].id.replace(/_div/, '');
    var qdiv = $('#' + question + '_div');
    
    // Move N/A field
    $(qdiv).find('.question_body').append($('#[% QuestionName() %]_div .response_row'));
    
    // N/A click event
    $(document).on('customGraphicalCheckbox', function(event, graphicalObj, inputObj, bln){
        if (inputObj.name == '[% QuestionName() %]_1') {
            // Disable and clear question
            if (bln) {
                // Inputs, textareas, selects
                $(qdiv).find('input[type=text]').val('').prop('disabled', true);
                $(qdiv).find('input[type=tel]').val('').prop('disabled', true);
                $(qdiv).find('textarea').val('').prop('disabled', true);
                $(qdiv).find('select').val('').prop('disabled', true);
                
                // Graphical radios and checks
                $(qdiv).find('input[type=radio]').each(function(){
                    SSI_RadioReset(this.name);
                    SSI_DisableGraphicalInput(this.id);
                });
                $(qdiv).find('input[type=checkbox]').each(function(){
                    if (this.id != '[% QuestionName() %]_1') {
                        SSI_SetSelect(this.id, false);
                        SSI_DisableGraphicalInput(this.id);
                    }
                });
                
                // Semantic diffs
                $(qdiv).find('.ui-slider').each(function(){
                    $(this).find('input').val('');
                    $(this).find('.ui-slider-handle').css('left', '50%');
                    $(this).slider('disable');
                });
                
                // Drag-and-drop ranking
                $(qdiv).find('.draggable_button').each(function(){
                    $(this).find('input').val('');
                    $(this).find('.rank_number').text('');
                });
                $(qdiv).find('.unranked_sort_area').append($(qdiv).find('.ranked_sort_area .draggable_button'));
                $(qdiv).find('.ui-sortable').sortable('option', 'cancel', '.draggable_button');
            }
        
            // Enable question
            else {
                // Inputs, textareas, selects
                $(qdiv).find('input[type=text]').prop('disabled', false);
                $(qdiv).find('input[type=tel]').prop('disabled', false);
                $(qdiv).find('textarea').prop('disabled', false);
                $(qdiv).find('select').prop('disabled', false);

                // Graphical radios and checks
                $(qdiv).find('input[type=radio]').each(function(){
                    SSI_EnableGraphicalInput(this.id);
                });
                $(qdiv).find('input[type=checkbox]').each(function(){
                    if (this.id != '[% QuestionName() %]_1') {
                        SSI_EnableGraphicalInput(this.id);
                    }
                });

                // Semantic diffs
                $(qdiv).find('.ui-slider').each(function(){
                    $(this).slider('enable');
                });
                
                // Drag-and-drop ranking
                $(qdiv).find('.ui-sortable').sortable('option', 'cancel', '');
            }
        }
    });
    $(document).trigger('customGraphicalCheckbox', [undefined, {name: '[% QuestionName() %]_1'}, SSI_GetValue('[% QuestionName() %]_1')]);
})

function SSI_CustomGraphicalCheckbox(graphicalObj, inputObj, bln) {
    $(document).trigger('customGraphicalCheckbox', [graphicalObj, inputObj, bln]);
}
</script>
answered Dec 18, 2019 by Jay Rutherford Gold (33,415 points)
Nice one Jay. That will come in handy for me too at some stage. And the usual thanks to Zachary too.
Yes, it's come in very useful for me a few different times now.
Thank  you Jay! I followed your instructions and it works fine.
...