- Posts: 20
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Ich meine es schon einmal irgendwo gesehen zu haben und das man es mit Java-Script in der zweiten Frage irgendwie hinbekommt und das zwischen den beiden Fragen der Browser einmal aktualisieren muss (Format: Frage für Frage).
Gott sei Dank.Leider war meine erneute Suche erfolglos.
Array filter (array_filter)
Description
The Array filter setting allows you to use any multiple choice question to select or set which responses are displayed in a subsequent list, array or multiple choice question.
Immer her damitJoffm wrote: Und dann wäre - wenn Du schon coole Features möchtest - eine dieser Optionen ganz nett.
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { // A function to add or remove rows of a multiple-short-text question function varLengthArray(qID) { // The HTML content of the Add/Remove elements - modify as you wish var addContent = '[+] Weitere Sorte'; var removeContent = '[-] Lösche Sorte'; // Insert the buttons $('#question'+qID+' .subquestion-list').append('<div id="addButton'+qID+'" class="control-button btn btn-primary">'+addContent+'</div><div id="removeButton'+qID+'" class="control-button btn btn-primary">'+removeContent+'</div>'); // Style the elements - you can modify here if you wish $('#question'+qID+' .control-button').css({ 'margin':'10px 0 0 10px', 'padding':'1px', 'text-align':'center', 'width':'auto', 'cursor':'pointer', 'float':'left', 'margin-bottom':'10px' }); // Initially hide the Remove element $( 'div#removeButton'+qID ).hide(); // Call the functions below when clicked $( 'div#addButton'+qID ).click(function (event) { addRow(qID); }); $( 'div#removeButton'+qID ).click(function (event) { removeRow(qID); }); // Function to add a row, also shows the Remove element and hides the function addRow(qID) { $('#question'+qID+' .answer-item:hidden:first').show(); $('div#removeButton'+qID).show(); if ($('#question'+qID+' .answer-item:visible').length == $('#question'+qID+' .answer-item').length) { $('div#addButton'+qID).hide(); } } // Function to remove a row and clear the input value function removeRow(qID) { $('#question'+qID+' .answer-item:visible:last').hide(); $('#question'+qID+' .answer-item:hidden input[type="text"]').each(function(i) { $(this).val('').trigger('keyup'); }); $( 'div#addButton'+qID ).show(); if ($('#question'+qID+' .answer-item:visible').length == 1) { $('div#removeButton'+qID).hide(); } } // Just some initialization stuff // Initially hide all except first row or any rows with populated inputs $('#question'+qID+' .answer-item input[type="text"]:not(:first)').each(function(i) { if($.trim($(this).val()) == '') { $(this).closest('.answer-item').hide(); } if ($('#question'+qID+' .answer-item:visible').length > 1) { // $('div#removeButton'+qID).show(); } }); } // Call the function with a question ID varLengthArray({QID}); }); </script>