Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Mathematical operations

Mathematical operations 5 years 3 months ago #64685

  • nina7777
  • nina7777's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 3
  • Karma: 3
Hello,

I use the replacement field to insert a previously given answer which works perfectly. However I need to multiply this value with 1.5.

So for example if the value from a previous given answer is 100 I want to in the next question show 150.

Is it possible and if so, how?

Best,
The administrator has disabled public write access.

Mathematical operations 5 years 3 months ago #64690

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5446
  • Thank you received: 814
  • Karma: 240
I think you can use the replacement field in Javascript. Then you just need to multiply it by the required factor in Javascript. I am not an expert on this though, so I can't give you a working example. But I think this is the way to go.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Mathematical operations 5 years 3 months ago #64697

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
Yup, you would need to do the math, something like:
var newValue = '{INSERTANSSGQA}' * 1.5;

And then insert the value into a <span> element in your question. Something like:
$('span.insertedText').text(newValue);

Have a look at this post for more details - www.limesurvey.org/en/forum/can-i-do-thi...rom-previous-answers
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 3 months ago by tpartner.
The administrator has disabled public write access.

Mathematical operations 5 years 3 months ago #65215

  • TMSWhite
  • TMSWhite's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 758
  • Thank you received: 84
  • Karma: 37
This will be easier in LimeSurvey 1.92 using ExpressionManager
The administrator has disabled public write access.

Mathematical operations 5 years 3 months ago #65217

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5446
  • Thank you received: 814
  • Karma: 240
Is there any prevision for 1.92?
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.
Time to create page: 0.279 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form