- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Problem with Array by column filter
- scampo02
- Topic Author
- Offline
- New Member
Less
More
10 years 4 weeks ago #106692
by scampo02
Problem with Array by column filter was created by scampo02
Hello Everybody:
I'm trying to use:
manual.limesurvey.org/Workarounds:_Manip...2Multiple-Options.22
But I can't make it work. I am using version 2.05. I follow all the instructions and it just hides/shows the whole question when I check one of the multiple options. I've been checking and I think the problem is over this line:
$('#question'+qArray+' .ans-'+ansCode3+'').show();
Because I found the description for each intem is nos question-item.ans..... Is that correct ? Does anybody knows if there's any new version of this workaround ?
Thanks
I'm trying to use:
manual.limesurvey.org/Workarounds:_Manip...2Multiple-Options.22
But I can't make it work. I am using version 2.05. I follow all the instructions and it just hides/shows the whole question when I check one of the multiple options. I've been checking and I think the problem is over this line:
$('#question'+qArray+' .ans-'+ansCode3+'').show();
Because I found the description for each intem is nos question-item.ans..... Is that correct ? Does anybody knows if there's any new version of this workaround ?
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
10 years 3 weeks ago #106719
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 Problem with Array by column filter
Add the following functions to the end of template.js instead of those indicated in the workaround. The script in the question source need not be modified.
Code:
function filterArrByCol(qMultiOpt, qArray, prevPage) { // If filter question is on a previous page, hide Q1 and check all "visible" boxes if(prevPage == 1) { $('#question'+qMultiOpt+' li[id</div>="javatbd"]:visible input.checkbox').attr('checked', true); $('#question'+qMultiOpt+'').hide(); } // Assign classes to the answer cells $('#question'+qArray+' td.answer-item').each(function(i){ var classArr = $(this).attr('class').split('answer_cell_00'); classArr = classArr[1].split(' '); var ansCode = classArr[0]; $(this).addClass('ans-'+ansCode+' filtered'); }); // Assign classes to the answer label cells $('#question'+qArray+' table.subquestions-list tbody tr:eq(0) td.answer-item').each(function(i){ var classArr2 = $(this).attr('class').split(' ans-'); var ansCode2 = classArr2[1]; $('#question'+qArray+' table.subquestions-list thead tr:eq(0) th:eq('+i+')').addClass('ans-'+ansCode2+''); }); // Fire the filter function on page load filterArr(qMultiOpt, qArray); // Listener on multi-opt checkboxes to fire the filter function $('#question'+qMultiOpt+' input.checkbox').click(function(){ filterArr(qMultiOpt, qArray); }); // On submit, clear all hidden radios of array $('#movenextbtn, #movesubmitbtn').click(function(){ $('#question'+qArray+' td.filtered:hidden').each(function(i){ $('input.radio', this).prop('checked', false); }); return true; }); } function filterArr(qMultiOpt, qArray) { if($('#question'+qMultiOpt+' input.checkbox:checked').length < 1) { // Hide the array if no multi-opt options are checked $('#question'+qArray+'').hide(); } else { $('#question'+qArray+'').show(); // Hide all columns of array $('#question'+qArray+' table.subquestions-list tbody td.answer-item, #question'+qArray+' table.question thead th').hide(); // Loop through multi-opt checkboxes and, if checked, show corresponding column of array $('#question'+qMultiOpt+' input.checkbox').each(function(i){ if($(this).prop('checked') == true) { var classArr3 = $(this).attr('id').split('X'+qMultiOpt); var ansCode3 = classArr3[1]; $('#question'+qArray+' .ans-'+ansCode3+'').show(); } }); } }
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
10 years 3 weeks ago #106721
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 Problem with Array by column filter
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: scampo02
The topic has been locked.
- scampo02
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
10 years 3 weeks ago #106761
by scampo02
Replied by scampo02 on topic Problem with Array by column filter
Thank you very much !!!
You guys rock !
You guys rock !
The topic has been locked.