Welcome, Guest
Username: Password: Remember me

TOPIC: Problem with Array by column filter

Problem with Array by column filter 4 months 3 weeks ago #106692

  • scampo02
  • scampo02's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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
The administrator has disabled public write access.

Problem with Array by column filter 4 months 3 weeks ago #106719

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4117
  • Thank you received: 760
  • Karma: 346
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.

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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Problem with Array by column filter 4 months 3 weeks ago #106721

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4117
  • Thank you received: 760
  • Karma: 346
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: scampo02

Problem with Array by column filter 4 months 3 weeks ago #106761

  • scampo02
  • scampo02's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Thank you very much !!!

You guys rock ! :cheer:
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.132 seconds
Donation Image