Welcome to the LimeSurvey Community Forum

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

Multiple short text: post-text for every subquestion

  • Jmantysalo
  • Jmantysalo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 6 months ago #158068 by Jmantysalo
Is it possible to make an array of text inputs like

I jump in a trampoline
1. about ___ times a day
2. about ___ times per week
3. about ___ times in a year

? I found manual.limesurvey.org/Workarounds:_Quest..._.22question_code.22 but there is not question.pstpl in newer version of LimeSurvey.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 6 months ago - 6 years 6 months ago #158099 by tpartner
The question.pstpl file does exist in the new versions of LimeSurvey and will through the LS 3.x series but I don't think you need to modify it for this layout.

1) Enter your prefixes and suffixes in the sub-question text, separated by commas as in the first screenshot below.

2) Set up your survey to use JavaScript and place the following script in the source of the question:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Insert the modified labels
    $('.control-label', thisQuestion).each(function(i) {
      var thisRow = $(this).closest('.answer-item');
      var labels = $(this).text().split(',')
      $('input.text', thisRow).before('<span class="inserted-prefix">'+$.trim(labels[0])+'</span>');
      $('input.text', thisRow).after('<span class="inserted-suffix">'+$.trim(labels[1])+'</span>');
    });
 
    // Some cleanup styling
    $('.control-label', thisQuestion).css({
      'display': 'none'
    });
    $('.form-group.row > div', thisQuestion).css({
      'float': 'none',
      'width': 'auto'
    });
    $('input.text', thisQuestion).css({
      'display': 'inline-block',
      'margin': '0 15px',
      'width': '75px'
    });
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...8-29.lss
File Size:16 KB





Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 6 months ago by tpartner.
The topic has been locked.
  • Jmantysalo
  • Jmantysalo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 6 months ago #158101 by Jmantysalo
Great! This works, many thanks.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 6 months ago #158123 by DenisChenu
Needed option in future : we have a lot of user asking it.

And we already have the option for numeric input ( using | as separator).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
4 years 1 month ago #193974 by surveySn
Hi Tpartner

It doesn't work,
3.21.1+191210
bootswatch and fruity
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193976 by Joffm
Hi,
well, the script was for version 2.50/2.74.
It is therefore not surprising, that it doesn't work in version 3.x.
Especially since the syntax of input.text changed to input[type="text"]

So replace accordingly and it will work.



Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193977 by tpartner
I was ignoring it until I got something like a polite request.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
4 years 1 month ago #193978 by surveySn
Hi tpartner, I'm sorry, I don't know what's impolite,

My mother tongue is not English. I translate it into English through translation software,

If my previous question is not polite, please forgive me, I'm sorry.
The topic has been locked.
More
4 years 1 month ago #193981 by surveySn
Hi Joffm
Perfect, thank you,
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose