Have an idea?

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

How do I make sure a rank can only be selected once?

asked Aug 16, 2016 by Jess
What do you mean?  Ranking questions should already require that each response be unique in order to submit the page.
Ok so I give people different attributes a,b,c and they have to decide which one is for them rank 1, which is rank 2 and which rank 3 - with regards to importance for example. Currently it is possible to select rank 1 for item a and for item b but I want that people have to make a real choice
What question type are you using?

If you are using a Ranking question, it should be impossible for a respondent to submit the page with two responses having the same value.

If you're not using a Ranking question, what question type are you using?  A Grid question, perhaps?
yes it is a grid one! Can you help me with that ? :(
Why not use a ranking question? No JavaScript required.

1 Answer

+1 vote
You can do this with custom JavaScript verification.  Click the "Advanced..." button in your grid's settings, go to "Custom JavaScript Verification," and check the checkbox.  This is the verification you'll want to use:

var rows = 4;
var ranks = [];
for (var row = 1; row <= rows; row++) {
    var rank = SSI_GetValue('GridQ_r' + row);
    if (ranks.indexOf(rank) != -1) {
        strErrorMessage = 'Ranks must be unique.';
    }
    ranks.push(rank);
}


"GridQ" should be replaced with the grid question's name.  Line 1 should be updated with the number of rows in the grid question.  Line 6 can be updated to change the error message you want displayed in this situation.
answered Aug 16, 2016 by Zachary Platinum Sawtooth Software, Inc. (75,550 points)
...