Multiple short text with different suffix

More
1 year 8 months 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!

Please Log in to join the conversation.

More
1 year 8 months ago - 1 year 8 months ago #205695 by tpartner
Add this script to the question source:

<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.
Attachments:
Last edit: 1 year 8 months ago by tpartner.

Please Log in to join the conversation.

More
1 year 8 months ago #205696 by ProjetLions
Thank you so much!!

Please Log in to join the conversation.

More
10 months 3 weeks 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!

Please Log in to join the conversation.

More
10 months 2 weeks ago #218004 by tpartner
<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.

Please Log in to join the conversation.

More
6 months 1 week 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!

Please Log in to join the conversation.

More
6 months 1 week ago #222035 by tpartner
You can insert HTML like this:

<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.
Attachments:

Please Log in to join the conversation.

More
6 months 1 week ago #222036 by Surveylab_KN
Thanks a lot for your fast answer!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now