- Posts: 9
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
string instead of number in slider
- supernul
- Topic Author
- Offline
- New Member
Less
More
6 years 11 months ago #152664
by supernul
string instead of number in slider was created by supernul
Hello everybody,
I created a question with a slider and I would like to show a string rather than a number above the cursor of the slider.
For instance:
... is less important than ...
option A ...
O---- ... option B
... is as important as ...
option A ...
O
... option B
Is it possible to use javascript as for the array multiple numeric to replace numbers by string ? I hope but I do not see how to do this.
I found solutions modifying template.css and other files but I cannot modify them.
Thank you for your help.
I created a question with a slider and I would like to show a string rather than a number above the cursor of the slider.
For instance:
... is less important than ...
option A ...
O---- ... option B
... is as important as ...
option A ...
O
... option B
Is it possible to use javascript as for the array multiple numeric to replace numbers by string ? I hope but I do not see how to do this.
I found solutions modifying template.css and other files but I cannot modify them.
Thank you for your help.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 11 months ago - 6 years 11 months ago #152671
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 string instead of number in slider
This script when inserted in the text of a slider question will replace the slider call-out values with custom labels. This demonstration script is for LS version 2.64.7 and uses a slider with values from 1-5.
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Define the new labels var labels = { 1: 'Is much less important than', 2: 'Is less important than', 3: 'Is as important as', 4: 'Is more important than', 5: 'Is much more important than' }; // Initial slider state $('.question-item', thisQuestion).each(function(i) { var thisRow = $(this); $('input[type="text"]', thisRow).on('slideEnabled', function(event, ui) { $('.tooltip-inner', thisRow).addClass('hidden'); $('.tooltip', thisRow).append('<div class="tooltip-inner inserted">'+labels[$('input[type="text"]', thisRow).val()]+'</div>'); $('.tooltip', thisRow).css('margin-left', '-'+($('.tooltip', thisRow).width()/2)+'px'); }); }); // Listener on sliders $('input[type="text"]', thisQuestion).on('slide slideStop', function(event, ui) { var thisRow = $(this).closest('.question-item'); $('.tooltip-inner.inserted', thisRow).text(labels[$('input[type="text"]', thisRow).val()]); $('.tooltip', thisRow).css('margin-left', '-'+($('.tooltip', thisRow).width()/2)+'px'); checkconditions($(this).val(), $(this).attr('name'), 'text'); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 6 years 11 months ago by tpartner.
The following user(s) said Thank You: supernul
The topic has been locked.
- supernul
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
6 years 11 months ago #152710
by supernul
Replied by supernul on topic string instead of number in slider
Thank you very much. That is more than I expected. It is exactly what I am looking for.
The topic has been locked.
- tammo
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 965
- Thank you received: 218
6 years 11 months ago #152712
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Replied by tammo on topic string instead of number in slider
Wow, Tony, I see so many solutions here. Did you ever think of publishing them in a searchable way, like in a Wiki/website of just LS solutions?
Tammo
Tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 11 months ago #152723
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 string instead of number in slider
Nope - too much work/maintenance so I just put the larger ones in the LS workarounds section . When time allows, I will convert this one to a jQuery plugin to make it a little more user-friendly and add it to the workarounds.Did you ever think of publishing them in a searchable way, like in a Wiki/website of just LS solutions?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- fair_lady
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
4 years 11 months ago #183681
by fair_lady
Replied by fair_lady on topic string instead of number in slider
Hello everyone,
and thank you, tpartner for the very helpful script. I used it for a while and it worked perfectly. No I have updated Limesurvey to Version 3.15.9+190214 and I can't find a way to make the slider work again.
Is there a similar script for the newer version of Limesurvey?
Thanks in advance for any suggestions on how to do this.
Cheers
and thank you, tpartner for the very helpful script. I used it for a while and it worked perfectly. No I have updated Limesurvey to Version 3.15.9+190214 and I can't find a way to make the slider work again.
Is there a similar script for the newer version of Limesurvey?
Thanks in advance for any suggestions on how to do this.
Cheers
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 11 months ago #183683
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 string instead of number in slider
See this post -
www.limesurvey.org/forum/design-issues/9...alues-as-text#170835
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- fair_lady
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
4 years 11 months ago #183684
by fair_lady
Replied by fair_lady on topic string instead of number in slider
Perfect! Thanks a lot!
I have somehow missed this!
I have somehow missed this!
The topic has been locked.