Column Piping Issue

More
3 years 5 months ago #100466 by wireframemedia
I have followed the tutorial here: manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascript
(Filter "Array by Column" Question With "Multiple-Options")

I cannot get this working. I have an urgent need to fix this for a large national company survey.

The first question is multiple choice (5-options). The second question is a Numerical Array (using checkboxes, for multiple select) and I need to pipe the answers chosen in the multiple-choice question to the columns (x-axix, horizontal) choices in the array. I need ONLY the ones chosen to show. I had it working so that all would show but then 2 or 3 column titles would be blank and still show checkboxes.

Can someone please help me with the correct javascript to use, where and how?

Please see image which shows the two questions.

Thank you!
Dawna
Attachments:

Please Log in to join the conversation.

More
3 years 5 months ago #100472 by holch
If you could put this into the vertical item list on the left (so switch the axis) the solution would be very simple: array_filter. I don't know if the array filter is available for the way you want to use it.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 5 months ago #100473 by holch
Seems like the array filter is also available for the array by column option:

manual.limesurvey.org/Question_type_-_Ar...r_.28array_filter.29

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 5 months ago #100477 by wireframemedia
Thanks but I need to use array (numbers) using checkboxes for Q2 and I need the columns to be piped in. I know it can be done as there is a tutorial on it, but it might be for an older version of LimeSurvey. I am hoping a Javascript Expert like Tony P. will know some quick JS code to do what I need.

Thanks though.
Dawna

Please Log in to join the conversation.

More
3 years 5 months ago #100478 by wireframemedia
I have tried this about 100 different ways and I am close. If someone knows some javascript to hide the empty columns (with no labels), I would be all set. This is due on Monday so I would GREATLY appreciate it.

I am attaching a copy of the survey.

Thanks.
Dawna
Attachments:

Please Log in to join the conversation.

More
3 years 5 months ago #100521 by tpartner
Add this script to the source of the array question. It will loop through all of the column headers and, if found to be empty, will hide all answer cells in that column.

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
 
		$('#question{QID} .subquestions-list thead th').each(function(i) {
			if($.trim($(this).text()).length == 0) {
				var colIndex = i;
				$(this).hide();
				$('#question{QID} .questions-list').each(function() {
					$('.question-item:eq('+colIndex+')', this).hide();
				});
			}
		});
	});
</script>

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: wireframemedia

Please Log in to join the conversation.

More
3 years 5 months ago #100523 by wireframemedia
Thanks Tony, that worked like a charm!
Exactly what I needed.
Great support as usual.

Take care.
Dawna

Please Log in to join the conversation.