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

THEMA: hide empty rows of a matrix

hide empty rows of a matrix 2 Jahre 10 Monate her #69372

  • Xtale
  • Xtales Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 17
  • Karma: 0
Hello!

My survey involves a matrix with checkboxes as follows:

var1 [] [] []
var2 [] [] []
var3 [] [] []
...

where the item "varX" is a previously answered item of an expandable 25-row textfield array. The array is not required to be filled out completely. Unfortunately, all cells including the empty ones are taken over to the checkbox array so I need to find a way to hide the empty rows.

I already messed around with some code snippets from a board user but I cant get it to work. I would appreciate some help.

Regards
x
$(document).ready(function() {
 
		handleRows(50);
 
		function handleRows(q1ID) {
 
			// Loop through all Q1 rows
			$('#question'+q1ID+' tbody[id^="javatbd"]').each(function(i) {
 
				// Hide empty rows in Q1
				if($('input[type="text"]:last', this).val() == '') { 
					$(this).hide(); 
				}
 
 
			});
		}
	});
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 10 Monate her #69392

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4190
  • Dank erhalten: 787
  • Karma: 359
Can you provide a sample survey?
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.
Letzte Änderung: 2 Jahre 10 Monate her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 10 Monate her #69433

  • Xtale
  • Xtales Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 17
  • Karma: 0
Thank you! Is this sufficent?
explain.jpg
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 10 Monate her #69439

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4190
  • Dank erhalten: 787
  • Karma: 359
Can you attach an export of the survey or group so we can test?
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 10 Monate her #69448

  • Xtale
  • Xtales Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 17
  • Karma: 0
oh sry, here is the file

Dateianhang:

Dateiname: limesurvey_survey_66537.lss
Dateigröße: 55 KB
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 10 Monate her #69453

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4190
  • Dank erhalten: 787
  • Karma: 359
No problem.

Add this script to the second group. It will hide all array rows that do not have a label or have the default sub-question text.
<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>
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: Xtale

Re: hide empty rows of a matrix 2 Jahre 9 Monate her #69479

  • Xtale
  • Xtales Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 17
  • Karma: 0
thank you! works perfect :) I'll donate to support your great work
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 9 Monate her #69497

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5325
  • Dank erhalten: 296
  • Karma: 249
Xtale schrieb:
thank you! works perfect :) I'll <a href='donate.limesurvey.org'>donate</a> to support your great work
Thanks for your support!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 9 Monate her #70897

  • socialstats
  • socialstatss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 2
  • Karma: 0
Hi tpartner,

I am a newbie and definitely not a coder. I am very impressed with LimeSurvey and your level of support here.

Your answer for Xtale is very nice, but I'm still don't get how to modify for my situation. My problem is similar to Xtale's except that in my survey design the original question is a one-row by five-column (1x5) text array:

SubQ: [__A1___] [__A2___] [__A3___] [__A4___] [__A5___]


My users are also not asked to complete all fields, so there may be less than all five.

-->I would like to take the answers users do provide for this question and put them alongside another text array (5x5) as SubQ prompts (same as Xtale's design except text-boxes, not check-boxes):


A1: [_____] [_____] [_____] [_____] [_____]

A2: [_____] [_____] [_____] [_____] [_____]

A3: [_____] [_____] [_____] [_____] [_____]

A4: [_____] [_____] [_____] [_____] [_____]

A5: [_____] [_____] [_____] [_____] [_____]


And also like Xtale, I would like to have rows presented only for those (Ax's) that were answered in the initial question.

I appreciate any guidance you can provide!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: hide empty rows of a matrix 2 Jahre 9 Monate her #70930

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4190
  • Dank erhalten: 787
  • Karma: 359
This solution should work for you as-is if you:

1) Place your questions on separate pages

2) Use {INSERTANS} to load the labels for the Q2 subquestions

3) Set up your survey to use JavaScript and place the script in the source of Q2
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.
Letzte Änderung: 2 Jahre 9 Monate her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.222 Sekunden
Donation Image