- Posts: 129
- Thank you received: 9
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Hide last 3 rows of an array question
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
5 years 8 months ago #170752
by paulfiner
Hide last 3 rows of an array question was created by paulfiner
I have a standard array question with 6 sub-questions that are randomised. I would like to hide the last 3 rows of the table so the respondent effectively sees 3 random sub-questions out of 6.
I'm sure the javascript for this is fairly simple but I'm struggling!
Thanks
Limesurvey v2.55
I'm sure the javascript for this is fairly simple but I'm struggling!
Thanks
Limesurvey v2.55
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10632
- Thank you received: 3697
5 years 8 months ago - 5 years 8 months ago #170755
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 Hide last 3 rows of an array question
[strike]You don't need JS for that. You can do it with sub-question relevance, counting the relevance status of other sub-questions.[/strike]
[EDIT]Further testing indicates that this does not work consistently[/EDIT]
[EDIT]Further testing indicates that this does not work consistently[/EDIT]
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 8 months ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 129
- Thank you received: 9
5 years 8 months ago - 5 years 8 months ago #170773
by paulfiner
Replied by paulfiner on topic Hide last 3 rows of an array question
Hi Tony,
Thanks for your reply and the sample survey. I tried this but it only ever shows the first 3 sub-question codes.
I need it to randomly show 3 of the 6 possible options - sorry if I didn't explain that originally.
Thanks
Thanks for your reply and the sample survey. I tried this but it only ever shows the first 3 sub-question codes.
I need it to randomly show 3 of the 6 possible options - sorry if I didn't explain that originally.
Thanks
Last edit: 5 years 8 months ago by paulfiner. Reason: spelling
The topic has been locked.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 129
- Thank you received: 9
5 years 8 months ago #170796
by paulfiner
Replied by paulfiner on topic Hide last 3 rows of an array question
In V2.55 I was only getting codes 1-3 randomized.
What would be the javascript code to hide row 4 of the table in an Array question?
What would be the javascript code to hide row 4 of the table in an Array question?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10632
- Thank you received: 3697
5 years 8 months ago #170797
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 Hide last 3 rows of an array question
Oh, yes, I see. I did not test thoroughly enough.
In that case, to allow for a "mandatory" setting, I would...
1) Insert a hidden (via CSS class) multiple choice question before the array with randomized sub-questions.
2) Add this script to the multiple-choice which will check the first 3 boxes:
3) Place an array filter on the array so only rows checked in the hidden question will be shown (and relevant).
Sample survey attached:
In that case, to allow for a "mandatory" setting, I would...
1) Insert a hidden (via CSS class) multiple choice question before the array with randomized sub-questions.
2) Add this script to the multiple-choice which will check the first 3 boxes:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Check first 3 options (but only if page has not been visited) if($('input:checkbox:checked', thisQuestion).length == 0) { $('input:checkbox:lt(3)', thisQuestion).each(function(i) { $(this).prop('checked', true); $(this).nextAll('input:hidden:eq(0)').val('Y'); checkconditions(this.value, this.name, this.type); }); } }); </script>
3) Place an array filter on the array so only rows checked in the hidden question will be shown (and relevant).
Sample survey attached:
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: DenisChenu
The topic has been locked.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 129
- Thank you received: 9
5 years 8 months ago #170799
by paulfiner
Replied by paulfiner on topic Hide last 3 rows of an array question
That's great! Works perfectly.
Thanks for your help Tony.
Thanks for your help Tony.
The topic has been locked.