- Posts: 28
- Thank you received: 0
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
- Topic Author
- Offline
- Junior Member
Less
More
8 months 1 week ago - 8 months 1 week ago #245798
by bellagambad
How do I change the text in the "add line" button (input on demand) was created 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11660
- Thank you received: 2742
8 months 1 week ago #245799
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic How do I change the text in the "add line" button (input on demand)
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:
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:
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.5.4.3+220926
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
8 months 1 week ago #245800
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How do I change the text in the "add line" button (input on demand)
You can place something like this in your custom.js file to modify the text in that button.
Alternatively, you could copy the core question theme as a custom theme and modify the answer.twig file.
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
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 28
- Thank you received: 0
8 months 1 week ago #245801
by bellagambad
Replied by bellagambad on topic How do I change the text in the "add line" button (input on demand)
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 ?
Thank you in advance, best regards,
David
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
8 months 1 week ago - 8 months 1 week ago #245803
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How do I change the text in the "add line" button (input on demand)
Change this line:
To this:
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
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 28
- Thank you received: 0
8 months 1 week ago #245804
by bellagambad
Replied by bellagambad on topic How do I change the text in the "add line" button (input on demand)
Worked like a charm, thank you !
David
David
Please Log in to join the conversation.