Quantcast
Channel: Topics in Category: Can I do this with LimeSurvey? - LimeSurvey forums
Viewing all articles
Browse latest Browse all 17529

Adding a number to rankings - by: tpartner

$
0
0
Set up your survey to use JavaScript and place the following script in the source of the question:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// Identify this question
		var qID = {QID};
		var thisQuestion = $('#question'+qID);
 
		// Listeners on the rankable items
		$('.ui-sortable', thisQuestion).on('sortstop', function(event, ui) {
			insertRankIndicators();
		});
		$('.ui-sortable li', thisQuestion).on('dblclick', function(event, ui) {
 
			setTimeout(function() {
				insertRankIndicators();
			}, 100);
		});
 
		// A function to insert ranking indicators
		function insertRankIndicators() {
			$('.inserted-rank', thisQuestion).remove();
			$('.dragDropRankList li', thisQuestion).each(function(i) {
				$(this).append('<span class="inserted-rank">#'+(i+1)+'</span>');
			});
		}
 
		// Insert some styles (these could be in template.css)
		var newStyles = '.ui-sortable-handle {\
							position: relative;\
						}\
						.ui-sortable li .inserted-rank {\
							position: absolute;\
							top: 5px;\
							right: 5px;\
						}';
		$('head').append('<style type="text/css">'+newStyles+'</style>');
	});
</script>

Viewing all articles
Browse latest Browse all 17529

Latest Images

Trending Articles



Latest Images