- Posts: 62
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Add some logics to Array ( Numbers ) checkbox style
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
7 years 8 months ago #138655
by Maverick87Shaka
Add some logics to Array ( Numbers ) checkbox style was created by Maverick87Shaka
Hi,
I'm here to ask some tips regarding the question type called:"Array (Numbers)"
I have one question with a lot of Y subquestion and only two X scale selection available with a checkbox, A or B.
What I need is to force participants to select only A, B or leave unchecked each Y subquestion. With default settings the users can check both A and B for each Y row.
In additional to this condition, I need to validate and let the users proceed only if they have checked only ten "A" subquestion, and five "B" checked.
Actually I'm using advanced option and I've set both minimum and maximum answers to 15, but in this case a people can select 15 "A" option without any B selected without any warning.
I know that using javascript it's possible to do almost "everything", but I'm asking if it's possible do this using the advanced settings option provided by default by the Limesurvey.
Thanks to all like usual
I'm here to ask some tips regarding the question type called:"Array (Numbers)"
I have one question with a lot of Y subquestion and only two X scale selection available with a checkbox, A or B.
What I need is to force participants to select only A, B or leave unchecked each Y subquestion. With default settings the users can check both A and B for each Y row.
In additional to this condition, I need to validate and let the users proceed only if they have checked only ten "A" subquestion, and five "B" checked.
Actually I'm using advanced option and I've set both minimum and maximum answers to 15, but in this case a people can select 15 "A" option without any B selected without any warning.
I know that using javascript it's possible to do almost "everything", but I'm asking if it's possible do this using the advanced settings option provided by default by the Limesurvey.
Thanks to all like usual
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
7 years 8 months ago #138668
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Add some logics to Array ( Numbers ) checkbox style
Hi,
You must use manual.limesurvey.org/Question_type_-_Ar...28em_validation_q.29
For "f they have checked only ten "A" subquestion, and five "B" checked"
Something like this For "What I need is to force participants to select only A, B or leave unchecked each Y"
Why ypou don't use an array question type ?
ELse you can do : The finally:
There can be soome error , but can be tested and improved
Denis
You must use manual.limesurvey.org/Question_type_-_Ar...28em_validation_q.29
For "f they have checked only ten "A" subquestion, and five "B" checked"
Something like this For "What I need is to force participants to select only A, B or leave unchecked each Y"
Why ypou don't use an array question type ?
ELse you can do : The finally:
Code:
(count(self.sq_A.NAOK)==10 and count(self.sq_B.NAOK)==5)) and ( (count(self.sq_SY01.NAOK) < 2) and (count(self.sq_SY02.NAOK) < 2) end ...... (count(self.sq_SY15.NAOK) < 2) )
Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 8 months ago #138736
by Maverick87Shaka
Replied by Maverick87Shaka on topic Add some logics to Array ( Numbers ) checkbox style
Thanks for suggestion,
I'm using the Array Numbers Type because I think for the users is better to have the checkbox, with the ability to clear his answer simply clicking again on the checkbox.
With the array type using radio button I have not found a simply way to allow user to clear a selection.
I'm now playing with the validation equation, but I have some trouble interpreting the meaning of: "self.sq_A"
What is exactly "sq_A"?
My question is made by a lot of sub-question Y scale, with code r1,r2 and so on.
And only two sub-question X-Scale, with code A and code B.
For example I try to change the code to "(count(self.sq_r1.NAOK) < 2)" but it's seams doesn't work, I'm not sure about the meaning of "sq_" and how to change for my question.
I'm using the Array Numbers Type because I think for the users is better to have the checkbox, with the ability to clear his answer simply clicking again on the checkbox.
With the array type using radio button I have not found a simply way to allow user to clear a selection.
I'm now playing with the validation equation, but I have some trouble interpreting the meaning of: "self.sq_A"
What is exactly "sq_A"?
My question is made by a lot of sub-question Y scale, with code r1,r2 and so on.
And only two sub-question X-Scale, with code A and code B.
For example I try to change the code to "(count(self.sq_r1.NAOK) < 2)" but it's seams doesn't work, I'm not sure about the meaning of "sq_" and how to change for my question.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
7 years 8 months ago #138743
by DenisChenu
You see the final formula in expression logic file , maybe you have r1 and r10 and r11 etc ....
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Add some logics to Array ( Numbers ) checkbox style
manual.limesurvey.org/Expression_Manager....27that.27_variablessq_X - where X is a row or column identifier. Only sub-questions matching pattern X are selected. Note that search is done on complete code identifier, then sq_X match and include subquestions nX, X, Xn (e.g. if you use sq_1, subquestions a1, 1a, 1, 11 or 001 was included). Put attention at dual scale question type where subquestions code are QCODE_SQCODE_1 and QCODE_SQCODE_1 and to ranking question type where subquestions code are QCODE_1,QCODE_2 ....
You see the final formula in expression logic file , maybe you have r1 and r10 and r11 etc ....
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 8 months ago - 7 years 8 months ago #138847
by Maverick87Shaka
Replied by Maverick87Shaka on topic Add some logics to Array ( Numbers ) checkbox style
Thanks for the TIP and the link, after changing some subquestion code to prevent missmatch, and making some test, I think to reach the code that I need to use, but unfortunately seams not works inside validation code box.
To make a test I write in the question the code to live view what the system counts, and the code seams works fine, but unfortunately the same code used inside validation box seams not work.
Here some screen of what I'm doing.
Thanks for any support.
Version 2.50+
To make a test I write in the question the code to live view what the system counts, and the code seams works fine, but unfortunately the same code used inside validation box seams not work.
Here some screen of what I'm doing.
Thanks for any support.
Version 2.50+
Last edit: 7 years 8 months ago by Maverick87Shaka.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
7 years 8 months ago #138848
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 Add some logics to Array ( Numbers ) checkbox style
Place your equation in the "Question validation equation" field under "Advanced settings", not in the "Validation" field - that's a legacy field for Regex's.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 8 months ago #138852
by Maverick87Shaka
Replied by Maverick87Shaka on topic Add some logics to Array ( Numbers ) checkbox style
I can't believe! I lost the count of many times I've try to edit my code, and finally the problem is not the code but the box that I'm using!
Thanks for support, I'm pretty new with this wonderful tool
Thanks for support, I'm pretty new with this wonderful tool
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 8 months ago #138862
by Maverick87Shaka
The only think that I would like to improve right now is the option for each row.
At the moment the user can check both A or B option, and got an error message when try to go in the next step or submit the survey.
It's possible to insert a javascript to "emulate" the same experience of radio box array? I would like to move the selection instead allow the multiple selection.
I don't know if, with this purpose in mind, it's better ( and easier ) to use normal array question type and changing style from radio radio button to checkbox, or add a "moving" rule with javascript to this array (number ) type.
Replied by Maverick87Shaka on topic Add some logics to Array ( Numbers ) checkbox style
I've finally put all the code together, and the validation works fine.tpartner wrote: Place your equation in the "Question validation equation" field under "Advanced settings", not in the "Validation" field - that's a legacy field for Regex's.
The only think that I would like to improve right now is the option for each row.
At the moment the user can check both A or B option, and got an error message when try to go in the next step or submit the survey.
It's possible to insert a javascript to "emulate" the same experience of radio box array? I would like to move the selection instead allow the multiple selection.
I don't know if, with this purpose in mind, it's better ( and easier ) to use normal array question type and changing style from radio radio button to checkbox, or add a "moving" rule with javascript to this array (number ) type.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
7 years 8 months ago #138890
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 Add some logics to Array ( Numbers ) checkbox style
If I understand correctly, you want only one checkbox per row clickable.
Adding this script to the question source will automatically uncheck all boxes in a row when a new box is checked:
Adding this script to the question source will automatically uncheck all boxes in a row when a new box is checked:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question //var thisQuestion = $('#question{QID}'); var thisQuestion = $('#question1955'); $('input.checkbox', thisQuestion).on('change', function(e) { cancelBubbleThis(e); if(this.checked) { var thisRow = $(this).closest('tr.subquestion-list'); var thisItem = $(this).closest('.answer-item'); $('.answer-item', thisRow).not(thisItem).each(function(i) { $('input.checkbox', this).prop('checked', false); $('input:hidden', this).attr('value', ''); checkconditions(this.value, this.name, this.type); }); } }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: Maverick87Shaka
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 8 months ago #138892
by Maverick87Shaka
Replied by Maverick87Shaka on topic Add some logics to Array ( Numbers ) checkbox style
Finally, all seams works really fine,both for users experience and data consistency. Thanks
The topic has been locked.
- surveySn
- Offline
- Premium Member
Less
More
- Posts: 136
- Thank you received: 4
5 years 1 month ago #179972
by surveySn
Replied by surveySn on topic Add some logics to Array ( Numbers ) checkbox style
automatically uncheck all boxes in a column when a new box is checked
could you help me?
could you help me?
The topic has been locked.