Have an idea?

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

Need checkbox to clear ranked items

I'm using the Ranged Drag-Drop question with an added select checkbox question giving them the option to not rank anything.  I've got everything working, including validation, but I would to add a 'clear ranked' onclick event to the checkbox just in case they rank a few items and then decide not to rank any.

Any ideas?
asked Jul 23, 2017 by jas8278 Bronze (750 points)

1 Answer

0 votes
Start by placing the not applicable question immediately after the ranged drag-and-drop's first helper.

Inside the not applicable question's footer and custom JavaScript verification, locate this line:

var question = $('#[% QuestionName() %]_div').prevAll('.question')[0].id.replace(/_div/, '');


Replace it with this new line:

var question = $('#[% QuestionName() %]_div').prevAll('.ranking.question')[0].id.replace(/_div/, '');


Next, disable require response in the ranking question.

Finally, locate this in the ranking question's custom JavaScript verification:

// Number ranked
var ranked = $('#[% QuestionName() %]_div .ranked_sort_area > .draggable_button').length;
if (ranked < min) {
    strErrorMessage = 'Please rank at least ' + min + ' item' + ((min != 1) ? 's' : '') + '.';
}


Replace that block with this:

// Not applicable
var naQuestion = $('#[% QuestionName() %]_div').nextAll('.select.question')[0].id.replace(/_div/, '');

// Number ranked
var ranked = $('#[% QuestionName() %]_div .ranked_sort_area > .draggable_button').length;
if (ranked < min && !SSI_GetValue(naQuestion + '_1')) {
    strErrorMessage = 'Please rank at least ' + min + ' item' + ((min != 1) ? 's' : '') + '.';
}
answered Jul 23, 2017 by Zachary Platinum Sawtooth Software, Inc. (127,375 points)
Hi Zachary,

The code above is validating, but it doesn't clear the ranked items in the right-hand column. The client wants them to move back into the "Items to Rank" column.

Is there any way to do that? Sorry if I wasn't clear about this.
That is already happening on my end.  Can you make sure you have the latest code for "Not Applicable: Per Question" from our website?
Hi Zachary,

That must have been it, got it working now!

Unfortunately, I have 1 more issue.  When you hit submit, the items that are left unranked all jump into the ranked column - the data records correctly, but our client wants them to stay in the unranked box.

Are you seeing this behavior?

Thanks so much for all your help!
Hi Zachary,

Never mind!  Have been working too many hours . . . found a chunk of code that was missing.

Thanks again for all your help!
Julia
...