- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Multiple choice and block selecting more then max
- cmd
- Topic Author
- Offline
- New Member
Less
More
9 years 4 months ago #115576
by cmd
Multiple choice and block selecting more then max was created by cmd
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.
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.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
9 years 4 months ago #115582
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on 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.
There you'll find:
Minimum answers
Maximum answers
This might help.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 4 months ago - 9 years 4 months ago #115591
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
Code:
<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: 9 years 4 months ago by tpartner.
The topic has been locked.
- cmd
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
9 years 4 months ago #115640
by cmd
Replied by cmd on topic Multiple choice and block selecting more then max
Thank you very much - works great!
Google told nothing so I just asked..
Google told nothing so I just asked..
The topic has been locked.
- faktormarc
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
9 years 2 months ago #117426
by faktormarc
Replied by faktormarc on 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!
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!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 2 months ago #117436
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
9 years 1 month ago #117438
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on 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.
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.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- faktormarc
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
9 years 1 month ago #117446
by faktormarc
Replied by faktormarc on topic Multiple choice and block selecting more then max
thank you, this solution works fine.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
9 years 1 month ago #117453
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Multiple choice and block selecting more then max
Toes, Tony, writes with his toes when the hands are occupied...
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 1 month ago #117456
by Ben_V
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)
Replied by Ben_V on 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)
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 1 month ago #117492
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
.
@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.
The topic has been locked.
- stephanied
- Offline
- Junior Member
Less
More
- Posts: 28
- Thank you received: 0
6 years 2 weeks ago #166549
by stephanied
Replied by stephanied on topic Multiple choice and block selecting more then max
This code works great in version 2.73.1. I would like to take it one step further and partially randomize and fix one answer to the bottom of the list. For multiple choice questions I typically use the following function:
Thanks in advance!
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { keepPos('{SGQ}',['SQ004|4']) // keepPos('{SGQ}',['code|position']) }); </script>
The topic has been locked.