Problem with Array by column filter

More
3 years 3 months ago #106692 by scampo02
scampo02 created the topic: Problem with Array by column filter
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

Please Log in to join the conversation.

More
3 years 3 months ago #106719 by tpartner
tpartner replied the 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.

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.

Please Log in to join the conversation.

More
3 years 3 months ago #106721 by tpartner
tpartner replied the 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

Please Log in to join the conversation.

More
3 years 3 months ago #106761 by scampo02
scampo02 replied the topic: Problem with Array by column filter
Thank you very much !!!

You guys rock ! :cheer:

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now