The LimeSurvey Fund-Raiser 2012 is complete. Thank you for donating a total of 25,000 USD!     List of donors »

Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1

THEMA: Hide empty rows of a Matrix

Hide empty rows of a Matrix 6 Monate 2 Wochen her #87952

  • snieuw
  • snieuws Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
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:
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Hide empty rows of a Matrix 6 Monate 1 Woche her #88064

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 2867
  • Dank erhalten: 426
  • Karma: 246
That group by itself doesn't help us see the problem.

Can you attach a sample survey?
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Hide empty rows of a Matrix 6 Monate 1 Woche her #88067

  • snieuw
  • snieuws Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
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:
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Hide empty rows of a Matrix 6 Monate 1 Woche her #88087

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 2867
  • Dank erhalten: 426
  • Karma: 246
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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Hide empty rows of a Matrix 6 Monate 1 Woche her #88109

  • snieuw
  • snieuws Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
Moderatoren: DenisChenu, ITEd
Ladezeit der Seite: 0.301 Sekunden
Donation Image