Prevent a user (with token) from selecting a specific answer in a ranking questi

4 years 3 months ago #90134 by brisyb
I have a ranking question where a user can rank three players in a sports team from 1 to 3. What I want to do is prevent a user (say using the lastname in their token) from selecting themself from the list of answers. Each player is in the list.

I need to be able to compare the users LASTNAME with the answer to see if they match, and if they do, prevent the user from selecting that answer.

The comparison is easy, but i dont know how to code it so they cant select themself.
for example I know I should code if(TOKEN:LASTNAME == 'Smith', R1_4 ... but what comes next to stop them being able to select it?

Please Log in to join the conversation.

4 years 3 months ago - 4 years 3 months ago #90146 by tpartner
I'm assuming you are using LS 2.0.

It's not easy to disable a single item of a sortable list (ranking) but I think it may be more user-friendly to remove the item entirely anyway.

Try adding this to the source of the question. The script will remove the ranking item that contains the exact text as the LASTNAME attribute.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() { 
		var lastName = '{TOKEN:LASTNAME}';
		$('.dragDropTable li').filter(function() {
			return $(this).text() == lastName;

Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 4 years 3 months ago by tpartner.

Please Log in to join the conversation.