Welcome to the LimeSurvey Community Forum

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

Multiple short text with different suffix

  • ProjetLions
  • ProjetLions's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 6 months ago #205686 by ProjetLions
Multiple short text with different suffix was created by ProjetLions
Hello! I want to create a multiple short text answer with different suffix for each "text". I want the question to look like this :

What is your dog's weight?
_______pound ________ounces

If it's not possible to create a question like the first example, the question could also look like this :
What is your dog's weight?
______pound
______ounces

Thanks in advance!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago - 3 years 6 months ago #205695 by tpartner
Replied by tpartner on topic Multiple short text with different suffix
Add this script to the question source:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Change the second suffix
    $('#question{QID} .suffix-text:eq(1)').text('ounces');
    });
</script>



Sample survey attached:

File Attachment:

File Name: limesurvey...4395.lss
File Size:18 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 6 months ago by tpartner.
The topic has been locked.
  • ProjetLions
  • ProjetLions's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 6 months ago #205696 by ProjetLions
Replied by ProjetLions on topic Multiple short text with different suffix
Thank you so much!!
The topic has been locked.
More
2 years 8 months ago #217958 by lime_novice
Replied by lime_novice on topic Multiple short text with different suffix
Hello,

I have been looking for a similar solution. What do I need to change in the script if I want to have three different suffixes?

Thanks a lot in advance!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 8 months ago #218004 by tpartner
Replied by tpartner on topic Multiple short text with different suffix
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Change the first suffix
    $('#question{QID} .suffix-text:eq(0)').text('years');
 
    // Change the second suffix
    $('#question{QID} .suffix-text:eq(1)').text('days');
 
    // Change the third suffix
    $('#question{QID} .suffix-text:eq(2)').text('hours');
    });
</script>

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
2 years 4 months ago #222033 by Surveylab_KN
Replied by Surveylab_KN on topic Multiple short text with different suffix
Hello,
thanks for this solution! I am very happy to find a lot of helpful solutions in the forum.

Is it possible to use bold font for a part of the text which is manipulated in javascript? I need to add different suffixes, but some parts of it should be bold. I tried to implement HTML-code, but it doesn't work. The HTML-code is shown as text. Unfortunaltely, my javascript knowldege is rather elimentary.

Thanks in advance!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 4 months ago #222035 by tpartner
Replied by tpartner on topic Multiple short text with different suffix
You can insert HTML like this:

Code:
<script type="text/javascript" data-author="Tony Partner">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Change the first suffix
    $('#question{QID} .suffix-text:eq(0)').html('<strong>Y</strong>ears');
 
    // Change the second suffix
    $('#question{QID} .suffix-text:eq(1)').html('<strong>D</strong>ays');
 
    // Change the third suffix
    $('#question{QID} .suffix-text:eq(2)').html('<strong>H</strong>ours');
    });
</script>

 

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
2 years 4 months ago #222036 by Surveylab_KN
Replied by Surveylab_KN on topic Multiple short text with different suffix
Thanks a lot for your fast answer!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose