Check out the LimeSurvey source code on GitHub!

limiting a number choices a user may select within a survey

More
5 years 9 months ago - 5 years 9 months ago #60942 by Aasifdevos
Good day

Could anyone please tell me if it is possible to limit/restrict a user to only select at most four out of fifteen individual questions??

Regards
Aasif
Last Edit: 5 years 9 months ago by Aasifdevos.

Please Log in to join the conversation.

More
5 years 9 months ago #60945 by lovepade
If you use the question type "multiple choice", you can set minimum and maximum number of choices under "advanced settings" - see: docs.limesurvey.org/Question+type+-+Mult...oice#Minimum_answers

Please Log in to join the conversation.

More
5 years 9 months ago #60951 by tpartner
You may be able to use this workaround to display a random set of questions - docs.limesurvey.org/tiki-index.php?page=...Random_question_sets

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Aasifdevos

Please Log in to join the conversation.

More
5 years 9 months ago #60970 by Aasifdevos
Hi Tony

I am not sure if i am saying the correct terminology.

Could i send you a link to my survey then you would be able to get a better understanding??

I would like to use this survey as an online election ballet.

I have +/- 9 questions within a question group.
Each question has a image of a candidate with a short description.

Each users should only be able to select four candidates at most.

Regards
Aasif

Please Log in to join the conversation.

More
5 years 9 months ago #60973 by tpartner
I get the idea now. What question types are you using?

Send me a PM with the survey link.

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
5 years 9 months ago #61029 by tpartner
Okay, I see that you are using a series of multiple-options questions in a group, each with a single checkbox to select a candidate.

Why don't you put all candidates into one multiple-options question and use the "Maximum answers" setting?

If you need to have separate questions, the following script will limit the number of checked boxes allowed on a page.

Set up your survey to use JavaScript and place the following script in the source of one the questions. Modify the maxChecked variable (line 5) and the alert (line 6) as necessary.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var maxChecked = 4;
		var msg = 'You can only select '+maxChecked+' choices';
 
		$('input.checkbox').click(function(){
			if($('input.checkbox:checked').length > maxChecked) {
				alert (msg);
				$(this).attr('checked', false);
			}
		});
	});
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Aasifdevos

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form