Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Adding multiple numerical input questions to an array

  • rbnbchr
  • rbnbchr's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 1 day ago #259004 by rbnbchr
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.17.1+190408
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hello,

How do I need to modify my code to have both short text questions in the array? Additionally, is it possible to have numeric inputs instead of short free text QT and how do I do customize the following code?

Appreciate any input!

<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
 
    // Identify the questions
    var thisQuestion = $('#question'+{QID}+'');
    var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)');
    var nextQuestions = $(nextQuestion1);
 
    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);
      var nextQ = nextQuestions;
      $('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow');
    }
 
    // Some styling...
    $('input[type="text"]', thisQuestion).css({
      'width': '100%'
    });
  });
</script>
Attachments:

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 1 day ago #259007 by tpartner
Use an array-numbers-text-inputs question type.

- manual.limesurvey.org/Question_type_-_Ar...ts_.28input_boxes.29

Cheers,
Tony Partner

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

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose