Welcome to the LimeSurvey Community Forum

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

Multiple numerical input - Exclude prefix/suffix in max sum label?

  • Magnar
  • Magnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 3 months ago - 6 years 3 months ago #162451 by Magnar
I'm using the multiple numerical input question type with prefixes and suffixes and would like to preset a maximum sum value. The label in the question container that shows said value contains those prefixes/suffixes as well, though. Is there a way to hide or even disable them so that only the value is shown?
Last edit: 6 years 3 months ago by Magnar.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #162455 by tpartner
I don't see any way to target that with CSS but placing this little script in the question source should do it:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:complete',function() {
    $('#question{QID} .multiplenumerichelp span[id^="totalvalue_"]').html($('#question{QID} .multiplenumerichelp span[id^="totalvalue_"] span[id^="LEMtailor_"]'));
  });
</script>


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: Magnar
The topic has been locked.
  • Magnar
  • Magnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 3 months ago - 6 years 3 months ago #162483 by Magnar
Nevermind, it works. Thank you very much for the quick response! It is kind of a bummer that this isn't possible through CSS though; giving those prefixes/suffixes a div and a class would make this so much easier and faster.

Would this also work with the template.js to affect all questions of this type? I'd rather not have other users play around with JS code in questions.
Last edit: 6 years 3 months ago by Magnar.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago - 6 years 3 months ago #162485 by tpartner
Yes, if placing the code in template.js, I would use this:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    // Remove text from total value elements    
    $('.numeric-multi').each(function(e) {
      $('.multiplenumerichelp span[id^="totalvalue_"]', this).html($('.multiplenumerichelp span[id^="totalvalue_"] span[id^="LEMtailor_"]', this));
    });
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 3 months ago by tpartner.
The following user(s) said Thank You: Magnar
The topic has been locked.
  • Magnar
  • Magnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 3 months ago #162498 by Magnar
Amazing, thank you so much tpartner!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose