Multiple choice and block selecting more then max

More
3 years 2 days ago #115576 by cmd
cmd created the topic: Multiple choice and block selecting more then max
Hi,
I want to ask about multiple choice question. I set max quantity of answears on 3, how to deny users to check more then 3 answears in real time. If 3 answears are checked then user can't check any other.

Please help and sorry for my English.

Please Log in to join the conversation.

More
3 years 1 day ago #115582 by jelo
jelo replied the topic: Multiple choice and block selecting more then max
Did you already checked the advanced settings of the question?

There you'll find:
Minimum answers
Maximum answers

This might help.

Please Log in to join the conversation.

More
3 years 1 day ago - 3 years 1 day ago #115591 by tpartner
tpartner replied the topic: Multiple choice and block selecting more then max
Adding a script like this, for example, will disable all unchecked boxes if 3 are checked. Modify "maxAnswers" as required.

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
 
		// Maximun answers
		var maxAnswers = 3;
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		function checkMax() {
			$('input.checkbox', thisQuestion).prop('disabled', false);
			if($('input.checkbox:checked', thisQuestion).length >= maxAnswers) {
				$('input.checkbox', thisQuestion).not(':checked').prop('disabled', true);
			}
		}
 
		// Initial checkbox states
		checkMax();
 
		// Listener on the checkboxes
		$('input.checkbox', thisQuestion).change(function(e) {
			checkMax();
		});
 
		// Remove any "disabled" properties before submitting
		$('#movenextbtn, #movesubmitbtn').bind('click', function () {			
			$('input.checkbox', thisQuestion).prop('disabled', false);
		});
 
    });
</script>

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

Please Log in to join the conversation.

More
3 years 22 hours ago #115640 by cmd
cmd replied the topic: Multiple choice and block selecting more then max
Thank you very much - works great!
Google told nothing so I just asked..

Please Log in to join the conversation.

More
2 years 9 months ago #117426 by faktormarc
faktormarc replied the topic: Multiple choice and block selecting more then max
Hey,

this solutions sounds perfect, but didnt work on my installation.

Where should i place the script? (Version 2.05+ Build 140612)

thx for your advice!

Please Log in to join the conversation.

More
2 years 9 months ago #117436 by tpartner
tpartner replied the topic: Multiple choice and block selecting more then max
Place the script in the source of the question - manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3F

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.

More
2 years 9 months ago #117438 by jelo
jelo replied the topic: Multiple choice and block selecting more then max
Since you are in the LS-Team, I wonder if implementing your workaround into the Limesurvey core are a discussion topic. For example this script here could be an additional option in the question.

What are the pro / contra for adding some of your "workarounds" to the codebase?

BTW: Your avatar cannot be true. How can you type with your hands behind your head? You are providing help here all the time.

Please Log in to join the conversation.

More
2 years 9 months ago #117446 by faktormarc
faktormarc replied the topic: Multiple choice and block selecting more then max
thank you, this solution works fine.

Please Log in to join the conversation.

More
2 years 9 months ago #117453 by holch
holch replied the topic: Multiple choice and block selecting more then max
Toes, Tony, writes with his toes when the hands are occupied... ;-)

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
2 years 9 months ago #117456 by Ben_V
Ben_V replied the topic: Multiple choice and block selecting more then max

Jelo wrote: How can you type with your hands behind your head?


You have to accept that Tony perfectly knows how to take advantage of some new and efficient wearable devices like those new but not publicy released google sunglasses. The red cap probably provides an incredible cooling solution normally used for data centers. Only the use of those 2 not referenced smartwatches remains unclear… :laugh:

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)

Please Log in to join the conversation.

More
2 years 9 months ago #117492 by tpartner
tpartner replied the topic: Multiple choice and block selecting more then max
@holch, @Ben_V: Yeah, yeah, funny guys :laugh: . Ben got most of the equipment right but don't overthink the watches - one, well, tells me the time, the other is actually a wristband for unlimited food and beer ;) .

@jelo, Please add the workaround to Feature Requests if you feel it's warranted.


.

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
Join our Newsletter!