Welcome to the LimeSurvey Community Forum

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

customize tip beneath question

  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 10 months ago #178068 by KompetenzZ
customize tip beneath question was created by KompetenzZ
Hi community,

most questions usually include a tip that says "Please choose one of the following options" or a hint text on how to fill out the question. I know there is this po file that can be used to change the tip question type specific, but for some questions I would need to customize the tip question specific or at least question group specific. I tried to edit the tip with javascript, I am sure I have errors. In the following case should be for a multiple choice question:

Code:
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function(){
    $('ls-question-message.ls-em-tip em_default.ls-em-success').text('custom tip text');
  });
</script>

Any suggestions welcome.

LS Version 3.14

Cheers kompetenzz
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #178074 by tpartner
Replied by tpartner on topic customize tip beneath question
I'm on my phone so can't debug fully but at the very least you are missing a period before the first class name in the identifier.

Code:
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function(){
    $('.ls-question-message.ls-em-tip em_default.ls-em-success').text('custom tip text');
  });
</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.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 10 months ago - 5 years 10 months ago #178093 by KompetenzZ
Replied by KompetenzZ on topic customize tip beneath question
Thank you very much.
When I replace the space with a period in addition to your comment after ".ls-question-message.ls-em-tip", it works:
Code:
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function(){
    $('.ls-question-message.ls-em-tip.em_default.ls-em-success').text('custom tip text');
  });
</script>

But now the exclamation mark symbol is gone. Therefore, I copied the html code from the exclamation mark symbol from here: fontawesome.com/v4.7.0/icon/exclamation-circle
And then I changed the ".text" to ".html" so that I can insert html code inside of the javascipt:
Code:
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function(){
                $('.ls-question-message.ls-em-tip.em_default.ls-em-success').html('<i class="fa fa-exclamation-circle" aria-hidden="true"></i> custom tip text');
  });
</script>

PS: I just saw that this procedure changes all tips in one question group (or question page when format: display question by question is activated) because all the tips of different question types use the same class. To solve this problem, the current question has to be referenced with "#question{QID}":
Code:
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function(){
                $('#question{QID} .ls-question-message.ls-em-tip.em_default.ls-em-success').html('<i class="fa fa-exclamation-circle" aria-hidden="true"></i> custom tip text');
  });
</script>

Sorry for the long post.

Cheers kompetenzz
Last edit: 5 years 10 months ago by KompetenzZ.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose