Welcome, Guest
Username: Password: Remember me

TOPIC: Mathematical operations

Mathematical operations 2 years 8 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.

Re: Mathematical operations 2 years 8 months ago #64690

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2442
  • Thank you received: 254
  • Karma: 94
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: Mathematical operations 2 years 8 months ago #64697

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 8 months ago by tpartner.
The administrator has disabled public write access.

Re: Mathematical operations 2 years 7 months ago #65215

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 81
  • Karma: 36
This will be easier in LimeSurvey 1.92 using ExpressionManager
The administrator has disabled public write access.

Re: Mathematical operations 2 years 7 months ago #65217

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2442
  • Thank you received: 254
  • Karma: 94
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.157 seconds
Donation Image