Array multi flex numbers Checkbox

More
5 years 8 months ago #72386 by rafael_ur
rafael_ur created the topic: Array multi flex numbers Checkbox
Hello,
I have a question Array Multi Flex Numbers with Checkbox:

ie:

Google
Yahoo
IE

Speed
Design
Accuray
All (*)
None (*)

Answers All and None are exclusive and if check All or None, answers Speed, Design and Accuray can´t check. How do I do?
Many thank,
Rafael

Please Log in to join the conversation.

More
5 years 8 months ago #72411 by Mazi
Mazi replied the topic: Array multi flex numbers Checkbox
Currently the only solution to achieve this is using some customized Javascript.

It might be possible using the Expression Manager at version 1.92RC, maybe TMSWhite can tell you more about it.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 8 months ago #72424 by TMSWhite
TMSWhite replied the topic: Array multi flex numbers Checkbox
Currently, array_multi_flexi supports one exclusive option, not two. I'll take a look and see if that is feasible.

Please Log in to join the conversation.

More
5 years 8 months ago #72432 by TMSWhite
TMSWhite replied the topic: Array multi flex numbers Checkbox
I misspoke.

"exclude_all_others" is only available for the Mulltiple Choice question types. It is implemented (in 1.92 and beyond) as sub-question-level relevance - so if you pick the exclusive option, the others disappear. Currently, there can only be one exclusive option, not two. However, supporting two could be nice.

The same logic could be used for array-style questions, but we'd need to add a 4th level of relevance checking. Currently, we check at the group, question, and array row (sub-question) level. To support multi-flexi, we'd need to also check at the individual cell level. This is probably do-able, but would take some work.

Please submit these two ideas to ideas.limesurvey.org so they can be considered for inclusion in future releases.

/Tom

Please Log in to join the conversation.

More
5 years 8 months ago - 5 years 8 months ago #72434 by tpartner
tpartner replied the topic: Array multi flex numbers Checkbox
To do this in 1.91 with JavaScript:

1) Set up your survey to use JavaScript .

2) Add the following script to the source of the array. Replace "QQ" with the array question ID and "NN" with the number of columns that you would like to be exclusive (in your case, 2).

The script adds click events to the answer elements to make the last NN columns exclusive.
<script type="text/javascript" charset="utf-8">
 
 
	$(document).ready(function() {
 
		exclusiveColumns(QQ, NN);
 
		function exclusiveColumns(qID, colNum) {
 
			// Find the number of answer columns
			var cols = $('#question'+qID+' tbody[id^="javatbd"]:first td').length;
 
			// Loop through all rows
			$('#question'+qID+' tbody[id^="javatbd"] tr').each(function(i) {
				// Loop through all answer cells and add some classes to define exclusive options
				$('td', this).each(function(i) {
					if(i < (cols - colNum)) {
						$(this).addClass('nonExclusiveOpt');
					} 
					else {
						$(this).addClass('exclusiveOpt');
					}
 
				});
 
			});
 
			// Click events on exclusive options
			$('.exclusiveOpt input[type="checkbox"]').click(function(event){
 
				var row = $(this).parents('tr:eq(0)');
 
				if($(this).attr('checked') == true) {
					$('input[type="checkbox"]', row).attr('checked', false);
					$(this).attr('checked', true);
				}
			});
			$('.exclusiveOpt').click(function(event){
 
				var cell = $(this);
				var row = $(this).parents('tr:eq(0)');
 
				// A small delay to allow the checkbox to be checked
				setTimeout(function() {
 
					if($('input[type="checkbox"]', cell).attr('checked') == true) {
						$('input[type="checkbox"]', row).attr('checked', false);
						$('input[type="checkbox"]', cell).attr('checked', true);
					}
 
				}, 250); 
			});
 
			// Click events on non-exclusive options
			$('.nonExclusiveOpt input[type="checkbox"]').click(function(event){
 
				var row = $(this).parents('tr:eq(0)');
 
				if($(this).attr('checked') == true) {
					$('.exclusiveOpt input[type="checkbox"]', row).attr('checked', false);
				}
			});
			$('.nonExclusiveOpt').click(function(event){
 
				var cell = $(this);
				var row = $(this).parents('tr:eq(0)');
 
				// A small delay to allow the checkbox to be checked
				setTimeout(function() {
 
					if($('input[type="checkbox"]', cell).attr('checked') == true) {
						$('.exclusiveOpt input[type="checkbox"]', row).attr('checked', false);
					}
 
				}, 250); 
			});
		}
	});
 
</script>

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 8 months ago by tpartner.

Please Log in to join the conversation.

More
5 years 8 months ago #72442 by rafael_ur
rafael_ur replied the topic: Array multi flex numbers Checkbox
Hello Tony,

It works perfectly.

Many thanks,

Rafael

Please Log in to join the conversation.

More
5 years 8 months ago #72445 by tpartner
tpartner replied the topic: Array multi flex numbers Checkbox
You're welcome Rafael.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now