Welcome to the LimeSurvey Community Forum

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

Hide specific comment box in multiple choice with comment

More
5 years 2 months ago #188253 by Spix
Hi Tony and all others.
I have a multiple choice question with comment, where I ask for the length of a tried treatment in months. One of the options is "no treatment tried" where the comment box, asking for the duration is redundant. I would like to get rid of that one specifically.

While were on it. Is there a way to have a "months" suffix behind the comment boxes?

Cheers,
Max
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 months ago #188255 by tpartner
Please always attach a survey export (.lss file) containing the relevant question(s) so we don't have to spend time creating surveys.

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
5 years 2 months ago #188256 by Spix
You're right. Here you go
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 months ago #188260 by tpartner
Add something like this to the question source:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Remove the first comment box
    $('#question{QID} ul.ls-answers li:eq(0) .comment-item').remove();
 
    // Insert comment suffix
    var suffixText = 'months';
    $('#question{QID} .comment-item').append('<span class="comment-suffix">'+suffixText+'</span>');
  });
</script>
 
<style type="text/css">
 
  #question{QID} input[type="text"] {
    width: auto;
    display: inline-block;
  }
</style>

You will also need to change the "Text input box width" to something like 50% to get it to look decent.



Sample survey attached:

File Attachment:

File Name: limesurvey...2183.lss
File Size:21 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Spix
The topic has been locked.
More
5 years 2 months ago #188291 by Spix
Thanks a lot. Works perfectly.
The topic has been locked.
More
5 years 2 months ago #188908 by surveySn
Hi Tpartner

How to add different suffixes?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 months ago #188915 by tpartner
Try this:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Remove the first comment box
    $('#question{QID} ul.ls-answers li:eq(0) .comment-item').remove();
 
    // Insert comment suffixes
    $('#question{QID} .comment-item:eq(0)').append('<span class="comment-suffix">Suffix 1</span>');
    $('#question{QID} .comment-item:eq(1)').append('<span class="comment-suffix">Suffix 2</span>');
    $('#question{QID} .comment-item:eq(2)').append('<span class="comment-suffix">Suffix 3</span>');
  });
</script>
 
<style type="text/css">
 
  #question{QID} input[type="text"] {
    width: auto;
    display: inline-block;
  }
</style>

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
5 years 2 months ago #189009 by surveySn
Perfect, thank you,Tpartner
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
7 months 6 days ago #260329 by Mazi

I have a multiple choice question with comment, where I ask for the length of a tried treatment in months. One of the options is "no treatment tried" where the comment box, asking for the duration is redundant. I would like to get rid of that one specifically.
 
This can be done easily with the following plugin which allows to define which options should not have a comment box shown:  survey-consulting.com/product/multi-opti...e-limesurvey-plugin/
Demo:  plugins.mysurveyhosting.com/index.php/344631?newtest=Y&lang=en

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose