Last Option In Array (Numbers) (Checkboxes) Row Excludes All Others

Mehr
1 Jahr 3 Monate her #167886 von krosser
Actually, I've made a test survey instead of that single question in LSQ.
:)

I'm using the latest LS 3.17 hosted on LS servers, not installed locally.
Anhänge:

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 3 Monate her - 1 Jahr 3 Monate her #168089 von tpartner
To render specific array columns as exclusive in 3.x...

1) Place this in your theme custom.js file:

// A jQuery plugin to render column(s) in checkbox arrays exclusive
(function( $ ){
 
	$.fn.cbExclusiveColumns = function(options) {  
 
		var opts = $.extend( {
			//columns: [3,4] // Column(s) to be exclusive (comma-separated) 
		}, options);
 
		return this.each(function() { 
 
			var thisQuestion = $(this)
 
			// Add some classes to the checkbox cells
			$('td.answer-item', thisQuestion).addClass('normal-item');
			$('tr.subquestion-list', thisQuestion).each(function(i) {
				var thisRow = $(this);
				$.each(opts.columns, function(i, val) {
					$('td.answer-item:eq('+(val-1)+')', thisRow).removeClass('normal-item').addClass('exclusive-item');
				});
			});
 
			// A listener on the checkboxes
			$('input[type="checkbox"]', thisQuestion).on('change', function (event) {
				handleExclusive($(this).closest('td'));
			});
 
			function handleExclusive(thisCell) {
 
				var thisRow = $(thisCell).closest('tr');
 
				// Uncheck the appropriate boxes in a row
				if ($(thisCell).hasClass('normal-item')) {
					$('.exclusive-item input[type="checkbox"]', thisRow).prop('checked', false);
					$('.exclusive-item input[type="text"]', thisRow).val('');
				}
				else {
					$('.answer-item', thisRow).not(thisCell).find('input[type="checkbox"]').prop('checked', false);
					$('.answer-item', thisRow).not(thisCell).find('input[type="text"]').val('');
				}
 
				// Check conditions (relevance)
				$('td.answer-item', thisRow).each(function(i) {
					var thisValue = '';
					if($('input[type="checkbox"]', this).is(':checked')) {
						thisValue = 1;
					}
					var thisSGQA = $('input[type="checkbox"]', this).attr('id').replace(/cbox_/, '');
 
					$('input[type="hidden"]', this).attr('value', thisValue);
					fixnum_checkconditions(thisValue, thisSGQA, 'hidden');
				});
			}
		});
 
	};
})( jQuery );


2) Place something like this in the source of the question (in this case, columns 3 and 4 will be exclusive):

<script type="text/javascript" charset="utf-8">
	$(document).on('ready pjax:scriptcomplete',function(){
		$('#question{QID}').cbExclusiveColumns({
			columns: [3,4] // Column(s) to be exclusive (comma-separated)
		});
	});
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Letzte Änderung: 1 Jahr 3 Monate her von tpartner.
Folgende Benutzer bedankten sich: krosser

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 3 Monate her #168101 von krosser
Have just tested it and it works nicely! Many thanks for your help, Tony!!

I'm using the latest LS 3.17 hosted on LS servers, not installed locally.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Monate 6 Tage her #184534 von KaryG
Hi,
I would like to alter the script from this post to make exclusive last 3 elements in each array row. Because I'm no javascript expert I don't know how to do it myself. Can you help me?
Thanks!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Monate 6 Tage her #184539 von Joffm
You saw this in tpartner's last post

<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
$('#question{QID}').cbExclusiveColumns({
columns: [3,4] // Column(s) to be exclusive (comma-separated)
});
});
</script>

Here you enter your "exclusive" columns.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Folgende Benutzer bedankten sich: KaryG

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Monate 6 Tage her #184545 von KaryG
Thanks for the help! I will try in this way.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 4 Tage her #185803 von davebostockgmail
Following on from this is there any way to make the last row of an array numbers with checkboxes exclusive

For example

A B
Option 1 [ ] [ ]
Option 2 [ ] [ ]
Exclusive [ ] [ ]

So in this case you can select both option 1 and 2 as a multiple but the exclusive option behaves as it would in a multiple choice question?

Version 3.17.5

Thanks

Dave

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 4 Tage her #185805 von Joffm
Hi,
can't you swap rows and columns?
Or is there such a large number of options that it would not fit the screen?

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 4 Tage her #185806 von krosser

davebostockgmail schrieb: Following on from this is there any way to make the last row of an array numbers with checkboxes exclusive

For example

A B
Option 1 [ ] [ ]
Option 2 [ ] [ ]
Exclusive [ ] [ ]

So in this case you can select both option 1 and 2 as a multiple but the exclusive option behaves as it would in a multiple choice question?

Version 3.17.5

Thanks

Dave


I think the workaround you need is in this thread...

I'm using the latest LS 3.17 hosted on LS servers, not installed locally.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 4 Tage her #185808 von davebostockgmail

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha