Hide empty rows of a Matrix

Mehr
4 Jahre 7 Monate her #87952 von snieuw
snieuw erstellte das Thema Hide empty rows of a Matrix
Hi everybody,
first of all: I know this was asked before. I just can not make this code work (taken from www.limesurvey.org/de/forum/can-i-do-thi...pty-rows-of-a-matrix ). Did something change there in the last updates? Unfortunately I'm not really fit in JavaScript, so please excuse if this is a stupid question. I have my questiongroup attached.

code in the description of the questiongroup:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Hide all rows without a row label
		$('table.question tbody').each(function(i, el){
 
			var rowLabel = $('th:first', el).text().replace(/[\s\n\t]/g,'');
 
			if(rowLabel == '' || rowLabel == 'Newansweroption') {
				$(el).hide();
			}
		});
 
		// Fix up row background colours
		$('table.question tbody:visible tr').each(function(i, el){
			$(el).removeClass('array1, array2');
			if(i % 2 == 0) {
				$(el).addClass('array2');
			}
			else {
				$(el).addClass('array1');
			}
		});
 
	});
</script>
 

Second question is te corresponding matrix, rows are filled correctly by the {if} statement, but empty rows are shown nevertheless.

Thanks a lot for any input!
Steffen
Anhang:

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 7 Monate her #88064 von tpartner
tpartner antwortete auf das Thema: Hide empty rows of a Matrix
That group by itself doesn't help us see the problem.

Can you attach a sample survey?

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

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 7 Monate her #88067 von snieuw
snieuw antwortete auf das Thema: Hide empty rows of a Matrix
Sorry, you are right of course. An example survey is attached. Code is in the group description, the only question that is in the group should not show the second (empty) row.

Thanks for helping :)
Steffen
Anhang:

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 7 Monate her #88087 von tpartner
tpartner antwortete auf das Thema: Hide empty rows of a Matrix
The script above is for an array-numbers-checkbox question type.

For the plain array question type use this:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Hide all rows without a row label
		$('table.question tr[id^="javatbd"]').each(function(i, el){
 
			var rowLabel = $('th:first', el).text().replace(/[\s\n\t]/g,'');
 
			if(rowLabel == '') {
				$(el).hide();
			}
		});
 
		// Fix up row background colours
		$('table.question tr[id^="javatbd"]:visible').each(function(i, el){
			$(el).removeClass('array1, array2');
			if(i % 2 == 0) {
				$(el).addClass('array2');
			}
			else {
				$(el).addClass('array1');
			}
		});
 
	});
</script>

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

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 7 Monate her #88109 von snieuw
snieuw antwortete auf das Thema: Hide empty rows of a Matrix
Thanks a lot, that fixed it! Very glad with the code :) Are there any hints or tutorials out there, on how to get the variables in JS? Tried with firebug, but had no success.

Anyway, works perfect, so thanks a lot

Greetings
Steffen

Bitte Anmelden um der Konversation beizutretten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten