- Posts: 6
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
The simplest way would be to use separate questions for the categories and maybe visually merge them with CSS.Since this roster is quite long, I would like to form categories of organisations (e.g. Restaurants, Processing Companies, Retail, etc.). How can I code this in Limesurvey?
Please Log in to join the conversation.
Please Log in to join the conversation.
/* Teilfragentexte linksbündig */ .ls-answers tbody .answertext { text-align: left; }<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#questionID'); // Define the sub-heading text strings var subHeading1 = '<span style="color:blue;font-size:12pt;font-weight:bold">Kategorie A</span>'; var subHeading2 = '<span style="color:blue;font-size:12pt;font-weight:bold">Kategorie B</span>'; var subHeading3 = '<span style="color:blue;font-size:12pt;font-weight:bold">Weitere</span>'; // Get the number of columns in the first row var columnsLength = $('tr.subquestion-list:eq(0) > *', thisQuestion).length; // Insert the new rows with sub-headings $('tr.subquestion-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>'); $('tr.subquestion-list:eq(3)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>'); $('tr.subquestion-list:eq(5)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading3+'</th></tr>'); // Fix up the row classes to maintain alternating row colors var rowClass = 1; $('table.subquestions-list tbody tr', thisQuestion).each(function(i) { if($(this).hasClass('sub-header-row')) { rowClass = 1; } else { rowClass++; $(this).removeClass('array1 array2'); if(rowClass % 2 == 0) { $(this).addClass('array2'); } else { $(this).addClass('array1'); } } }); // Call the function to make the last two options in each array row exclusive excludeOpt('questionID'); // Hide short-text questions and move them into the array hideAndMoveShortText(); }); // Eine Funktion, um die letzten zwei Optionen in jeder Array-Zeile exklusiv zu machen function excludeOpt(questionID) { var thisQuestion = $('#questionID'); // Fügen Sie den Checkbox-Zellen einige Klassen hinzu $('td.checkbox-item', thisQuestion).addClass('normal-item'); // Schleife durch jede Zeile und markiere die letzten beiden Elemente als exklusiv $('tr.subquestion-list', thisQuestion).each(function(i) { var $cells = $(this).find('.checkbox-item'); $cells.eq(-1).removeClass('normal-item').addClass('exclusive-item'); $cells.eq(-2).removeClass('normal-item').addClass('exclusive-item'); }); // Ein Listener auf den Kontrollkästchen $('input[type="checkbox"]', thisQuestion).on('change', function (event) { handleExclusive($(this).closest('td')); }); } // Funktion zum Ausblenden und Verschieben von Kurztextfragen function hideAndMoveShortText() { // Identify the questions var thisQuestion = $('#questionID'); var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)'); var nextQuestion2 = $(thisQuestion).nextAll('.text-short:eq(1)'); var nextQuestions = $(nextQuestion1).add(nextQuestion2); var nextLength = nextQuestions.length; var sqLength = $('tr.answers-list', thisQuestion).length; // Hide the short-text questions $(nextQuestions).hide(); // Move the hidden text inputs into the array for (i = 0; i < nextLength; i++) { var workingIndex = (sqLength - 1) - (nextLength - i) + 1; // Erhöhen Sie den Index um 1 var nextQ = nextQuestions[i]; var answerText = $(nextQ).find('input[type="text"]').val(); var inputElement = '<input type="text" value="' + answerText + '" disabled>'; $('th.answertext:eq('+workingIndex+')', thisQuestion).append(inputElement).closest('tr').addClass('otherRow'); } // Some styling... $('input[type="text"]', thisQuestion).css({ 'width': '100%' }); } function handleExclusive(thisCell) { var thisRow = $(thisCell).closest('tr'); // Aktivieren oder deaktivieren Sie die entsprechenden Kontrollkästchen in einer Zeile if ($(thisCell).hasClass('normal-item')) { $('.exclusive-item input[type="checkbox"]', thisRow).prop('checked', false); } else { $('.normal-item input[type="checkbox"]', thisRow).prop('checked', false); } // Überprüfen Sie die Bedingungen (Relevanz) $('td.checkbox-item', thisRow).each(function(i) { var thisValue = ''; if($('input[type="checkbox"]', $(this)).is(':checked')) { thisValue = 1; } var thisSGQA = $('input[type="checkbox"]', $(this)).attr('id').replace(/cbox_/, ''); $('input[type="hidden"]', $(this)).attr('value', thisValue); fixnum_checkconditions(thisValue, thisSGQA, 'hidden'); }); } </script> <style type="text/css">/* Teilfragentexte linksbündig */ .ls-answers tbody .answertext { text-align: left; } </style>[/i]
Please Log in to join the conversation.
$('tr.subquestion-list:eq(5)', thisQuestion).before('<tr class="sub-header-row">\ <th>'+subHeading3+'</th>\ <th style="font-weight:bold;text-align:center">Trade Relationship</th>\ <th style="font-weight:bold;text-align:center">Collaboration Relationship</th>\ <th style="font-weight:bold;text-align:center">No Relation</th>\ <th style="font-weight:bold;text-align:center">No answer</th>\ </tr>');
var subHeading1 = '<th style="color:maroon;font-size:12pt;font-weight:bold">Category A-B</th>'; var subHeading2 = '<th style="color:maroon;font-size:12pt;font-weight:bold">Category C-E</th>'; var subHeading3 = '<th style="color:maroon;font-size:12pt;font-weight:bold">Category F-G</th>'; var option1 = '<th style="font-weight:bold;text-align:center">Trade Relationship</th>'; var option2 = '<th style="font-weight:bold;text-align:center">Collaboration Relationship</th>'; var option3 = '<th style="font-weight:bold;text-align:center">No Relationship</th>'; var option4 = '<th style="font-weight:bold;text-align:center">No answer</th>'; ... // Insert the new rows $('tr.subquestion-list:eq(5)', thisQuestion).before('<tr class="sub-header-row">'+subHeading3+option1+option2+option3+option4+' </tr>');
Please Log in to join the conversation.
Please Log in to join the conversation.
function removeRepeatedHeadings() { var thisQuestion = $('#question128793'); var repeatedHeadings = $('table.subquestions-list thead th.repeated-heading', thisQuestion); repeatedHeadings.closest('tr').remove(); }
Please Log in to join the conversation.
Please Log in to join the conversation.
// Funktion zum Ausblenden und Verschieben von Kurztextfragenfunction hideAndMoveShortText() { // Identify the questions var thisQuestion = $('#question128793'); var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)'); var nextQuestion2 = $(thisQuestion).nextAll('.text-short:eq(1)'); var nextQuestions = $(nextQuestion1).add(nextQuestion2); var nextLength = nextQuestions.length; var sqLength = $('tr.answers-list', thisQuestion).length; // Hide the short-text questions $(nextQuestions).hide(); // Move the hidden text inputs into the array for (i = 0; i < nextLength; i++) { var workingIndex = (sqLength - 1) - (nextLength - i) + 1; // Erhöhen Sie den Index um 1 var nextQ = nextQuestions[i]; var answerText = $(nextQ).find('input[type="text"]').val(); var inputElement = '<input type="text" value="' + answerText + '">'; $('th.answertext:eq('+workingIndex+')', thisQuestion).append(inputElement).closest('tr').addClass('otherRow'); } // Some styling... $('input[type="text"]', thisQuestion).css({ 'width': '100%' });}
Please Log in to join the conversation.
Can you help me again?
Please Log in to join the conversation.