- Posts: 16
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
count checked answers in multiple choice question
- barbacot
- Topic Author
- Offline
- New Member
Less
More
11 years 9 months ago - 11 years 9 months ago #81247
by barbacot
count checked answers in multiple choice question was created by barbacot
I installed latest version of limesurvey to give it a try.
i like it very much but I need advise on how to do one thing:
I have a multiple choices question with approximately 70 choices. From this a user must check at most 12. Since he can check so many answers I want a possibility for him to show near the question (up or down) a field with how many choices he checked (real time) or how many he has left (this is even better) -some kind of real time counter.
Is this possible???
I found on the internet this script but for some reason it doesn't work:
where 76 and 77 are the question's ID (I think...).
Can someone please tell me if there is something wrong with this code or if there is any other possibility to achieve what I described at the start of the topic?
i like it very much but I need advise on how to do one thing:
I have a multiple choices question with approximately 70 choices. From this a user must check at most 12. Since he can check so many answers I want a possibility for him to show near the question (up or down) a field with how many choices he checked (real time) or how many he has left (this is even better) -some kind of real time counter.
Is this possible???
I found on the internet this script but for some reason it doesn't work:
Code:
<script type="text/javascript"> function Custom_On_Load(){ $(document).ready(function() { /* Hide the answer box from this current question, because we will store the value of the count in this question */ $( ‘#question77′ ).hide(); $( ‘#question76 td.answer input.checkbox’ ).change(function() { var checkedCount = 0; $( ‘#question76 td.answer input.checkbox’ ).each(function(i) { if ( $( this ).attr(‘checked’) == true ) { checkedCount++; } }); if ( checkedCount > 1 ) { $( ‘#question77 td.answer input.checkbox’ ).attr(‘checked’, true); } else { $( ‘#question77 td.answer input.checkbox’ ).attr(‘checked’, false); } }); }); } </script>
where 76 and 77 are the question's ID (I think...).
Can someone please tell me if there is something wrong with this code or if there is any other possibility to achieve what I described at the start of the topic?
Last edit: 11 years 9 months ago by barbacot.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
11 years 9 months ago #81262
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 count checked answers in multiple choice question
That is obsolete code to populate a hidden question.
If you have 70 choices, where do you want to insert the counter? With so many answers, it may not always be visible as the respondent scrolls.
If you have 70 choices, where do you want to insert the counter? With so many answers, it may not always be visible as the respondent scrolls.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- barbacot
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
11 years 9 months ago - 11 years 9 months ago #81264
by barbacot
Replied by barbacot on topic count checked answers in multiple choice question
The answer are not so big and on two columns.
I would want the counter at the bottom of the question because the user start from the top and it is more important for him to see the remaing choices at the bottom.
If a counter is a bad idea in this context than maybe how to disable the unchecked checkboxes after the user chooses the maximum allowed responses with a messagebox to tell him that he checked all the maximum answers.
I would want the counter at the bottom of the question because the user start from the top and it is more important for him to see the remaing choices at the bottom.
If a counter is a bad idea in this context than maybe how to disable the unchecked checkboxes after the user chooses the maximum allowed responses with a messagebox to tell him that he checked all the maximum answers.
Last edit: 11 years 9 months ago by barbacot.
The topic has been locked.
- TMSWhite
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 84
- Thank you received: 21
11 years 9 months ago #81281
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic count checked answers in multiple choice question
It is possible to show such a real-time counter.
You might want to do two things:
(1) Use the advanced question option to set the max number of allowable answers to 12. This will dynamically color code the message "Please select up to 12 answers", making it turn pink (a warning color) if the user selects too many.
(2) Add a tailored message to the help text, saying "Please check {x} more boxes", where {x} is an equation like this (assuming your question is called "q"):
Here is a working example of something similar. Note at the bottom of the figure that it dynamically counts how many numbers have been entered in the preceding questions.
You might want to do two things:
(1) Use the advanced question option to set the max number of allowable answers to 12. This will dynamically color code the message "Please select up to 12 answers", making it turn pink (a warning color) if the user selects too many.
(2) Add a tailored message to the help text, saying "Please check {x} more boxes", where {x} is an equation like this (assuming your question is called "q"):
Code:
{12 - count(q_1, q_2, q_3, ..., q_70)}
Here is a working example of something similar. Note at the bottom of the figure that it dynamically counts how many numbers have been entered in the preceding questions.
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
The following user(s) said Thank You: bayemanel
The topic has been locked.
- barbacot
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
11 years 9 months ago #81288
by barbacot
Replied by barbacot on topic count checked answers in multiple choice question
Thank you very much.
It is working...
One more question if you are so kind: is there some kind of scripting event so that all the checked answers in multiple choices question become red or green or any other color when the user check the corresponding checkboxes???
It is working...
One more question if you are so kind: is there some kind of scripting event so that all the checked answers in multiple choices question become red or green or any other color when the user check the corresponding checkboxes???
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
11 years 9 months ago #81291
by tpartner
Add the following to the end of template.js:
And then add something like this to the end of template.css:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic count checked answers in multiple choice question
is there some kind of scripting event so that all the checked answers in multiple choices question become red or green or any other color when the user check the corresponding checkboxes?
Add the following to the end of template.js:
Code:
$(document).ready(function(){ // Listener on the checkboxes $('input.checkbox').click(function(e){ if($(this).is(':checked')) { $(this).next('label').addClass('checkedLabel'); } else { $(this).next('label').removeClass('checkedLabel'); } }); });
And then add something like this to the end of template.css:
Code:
.checkedLabel { color:#009900; }
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- barbacot
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
11 years 9 months ago #81304
by barbacot
Replied by barbacot on topic count checked answers in multiple choice question
It works beautifully. :woohoo:
Thank you very much for your kind support.
Great open source application.
Thank you very much for your kind support.
Great open source application.
The topic has been locked.
- Ryuniri_44052
- Offline
- Banned
Less
More
- Posts: 40
- Thank you received: 0
8 years 10 months ago #119646
by Ryuniri_44052
Replied by Ryuniri_44052 on topic count checked answers in multiple choice question
Hey,
for me this script is not working. I can not recognize any differences after embedding the two scripts into the two respective files.
Is this script still working with the latest LimeSurvey Version?
for me this script is not working. I can not recognize any differences after embedding the two scripts into the two respective files.
Is this script still working with the latest LimeSurvey Version?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 10 months ago #119663
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 count checked answers in multiple choice question
Works for me in the latest version. Do you have any JavaScript errors in the console? Try using Firebug or developer tools to see if the "checkedLabel" class is being applied.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1223
- Thank you received: 351
8 years 10 months ago #119670
by Ben_V
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 count checked answers in multiple choice question
Related 100% EM syntax for a "Q1" question
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.