Check out the LimeSurvey source code on GitHub!

Mathematical operations

More
5 years 5 months ago #64685 by nina7777
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,

Please Log in to join the conversation.

More
5 years 5 months ago #64690 by holch
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.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
5 years 5 months ago - 5 years 5 months ago #64697 by tpartner
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 5 months ago by tpartner.

Please Log in to join the conversation.

More
5 years 4 months ago #65215 by TMSWhite
This will be easier in LimeSurvey 1.92 using ExpressionManager

Please Log in to join the conversation.

More
5 years 4 months ago #65217 by holch
Is there any prevision for 1.92?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form