Welcome to the LimeSurvey Community Forum

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

How do I change the text in the "add line" button (input on demand)

  • bellagambad
  • bellagambad's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 months 1 week ago - 8 months 1 week ago #245798 by bellagambad
LimeSurvey version: 5.4.3+220926
own server
Survey theme/template: custom fruity
==================
Hello,
I am trying to change the text in the "add line" button (question type : input on demand) by using a script but I haven't found a solution yet. I found a similar topic about the "submit" and "previous" button but not the "add line" button. I tried to use the web dev tool to find the class and modify the script available in this topic but it didn't work :  forums.limesurvey.org/forum/can-i-do-thi...-text?start=0#223958   
Any help would be appreciated ! 
Thanks in advance,
David
Last edit: 8 months 1 week ago by bellagambad.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 months 1 week ago #245799 by holch
This text is part of the language files. Depending on which language you are using, you will need to "translate" it in your installation / your local language files.

If you are using just one language, you might be able to change the text via Javascript, but I have no idea how this works. Need to wait for Tpartner or maybe Joffm.

Off topic:

5.4.3+220926

Your version was released on 26/09/2022, so it is almost 1 year old now and hasn't received any update, bug fix or security patch since then. I highly recommend to consider an update to the latest LS 5.x version.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 months 1 week ago #245800 by tpartner
You can place something like this in your custom.js file to modify the text in that button.

Code:
$(document).on('ready pjax:scriptcomplete',function(){
 
  var labels = {
    'en': 'New label',
    'fr': 'Nouvelle étiquette',
    'de': 'Neues label',
    'es': 'Nueva etiqueta',
  };
 
  var lang = $('html').attr('lang'); 
 
  if(lang in labels) {
    $('.btn.selector--inputondemand-addlinebutton').text(labels[lang]);
  }
});

Alternatively, you could copy the core question theme as a custom theme and modify the answer.twig file.

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: holch

Please Log in to join the conversation.

  • bellagambad
  • bellagambad's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 months 1 week ago #245801 by bellagambad
Thank you both for your messages. I will ask the IT department of my organization to update LS, thank you for pointing this out.

tpartner, I used your code in the custom.js and it worked perfectly, thank you very much. I'd like to add an fa icon in the label. May I ask you what's wrong in the following code ?
Code:
$(document).on('ready pjax:scriptcomplete',function(){
  var labels = {
    'en': '<i class="fa fa-plus"></i> Add line',
    'fr': '<i class="fa fa-plus"></i> Ajouter une ligne',
  };
  var lang = $('html').attr('lang'); 
  if(lang in labels) {
    $('.btn.selector--inputondemand-addlinebutton').text(labels[lang]);
  }
});

Thank you in advance, best regards,

David

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 months 1 week ago - 8 months 1 week ago #245803 by tpartner
Change this line:
Code:
$('.btn.selector--inputondemand-addlinebutton').text(labels[lang]);

To this:
Code:
$('.btn.selector--inputondemand-addlinebutton').html(labels[lang]);

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 months 1 week ago by tpartner.

Please Log in to join the conversation.

  • bellagambad
  • bellagambad's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 months 1 week ago #245804 by bellagambad
Worked like a charm, thank you !
David

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose