Welcome, Guest
Username: Password: Remember me

TOPIC: Array multi flex numbers Checkbox

Array multi flex numbers Checkbox 2 years 10 months ago #72386

  • rafael_ur
  • rafael_ur's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 74
  • Karma: 0
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
The administrator has disabled public write access.

Re: Array multi flex numbers Checkbox 2 years 10 months ago #72411

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5426
  • Thank you received: 307
  • Karma: 252
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Array multi flex numbers Checkbox 2 years 10 months ago #72424

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Currently, array_multi_flexi supports one exclusive option, not two. I'll take a look and see if that is feasible.
The administrator has disabled public write access.

Re: Array multi flex numbers Checkbox 2 years 10 months ago #72432

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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
The administrator has disabled public write access.

Re: Array multi flex numbers Checkbox 2 years 10 months ago #72434

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 10 months ago by tpartner.
The administrator has disabled public write access.

Re: Array multi flex numbers Checkbox 2 years 10 months ago #72442

  • rafael_ur
  • rafael_ur's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hello Tony,

It works perfectly.

Many thanks,

Rafael
The administrator has disabled public write access.

Re: Array multi flex numbers Checkbox 2 years 10 months ago #72445

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
You're welcome Rafael.
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.133 seconds
Donation Image