Welcome to the LimeSurvey Community Forum

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

Multiple short text with different suffix

More
6 years 2 days ago #205686 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.
More
6 years 2 days ago - 6 years 2 days ago #205695 by tpartner
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.33 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 2 days ago by tpartner.
The topic has been locked.
More
6 years 2 days ago #205696 by ProjetLions
Thank you so much!!
The topic has been locked.
More
5 years 2 months ago #217958 by lime_novice
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.
More
5 years 2 months ago #218004 by tpartner
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
4 years 10 months ago #222033 by Surveylab_KN
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.
More
4 years 10 months ago #222035 by tpartner
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
4 years 10 months ago #222036 by Surveylab_KN
Thanks a lot for your fast answer!
The topic has been locked.
Moderators: tpartner, holch

Lime-years ahead

Online-surveys for every purse and purpose