- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Javascript to show calculations based on 2 question
6 years 2 weeks ago - 6 years 2 weeks ago #149310
by mumbix
Javascript to show calculations based on 2 question was created by mumbix
Hi im fairly new to coding java queries to lime survey and wanted to know how i could multiply Q1 by Q2 using java script( both list radios)
so far i have tried this script in pentaho and seems to give the desired results but limesurvey is not having any of it pleasehelp...
so far i have tried this script in pentaho and seems to give the desired results but limesurvey is not having any of it pleasehelp...
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var Q2 = {INSERTANS:86119X5228X47098}; var Q3 = {INSERTANS:86119X5228X47080}; var Cost = '' ; if (Q3 == '25% discount so £14.85 for one a year subscription (UK)' && Q2 != '' || Q2 != null || Q2 != 'Error(86119X5228X47098)') { Cost = (14.85 * Q2); } else if (Q3 == '25% discount so £28.00 for a two year subscription (UK)' && Q3 != '' || Q3 != null && Q2 != ''|| Q2 != null || Q2 != 'Error(86119X5228X47098)'){ Cost = (28 * Q2); } else if (Q3 == '25% discount so £20.25 for one a year subscription (ROW)' && Q3 != '' || Q3 != null && Q2 != '' || Q2 != null || Q2 != 'Error(86119X5228X47098)'){ Cost = (20.25 * Q2); } else if (Q3 == '25% discount so £38.00 for a two year subscription (ROW)' && Q3 != '' || Q3 != null && Q2 != '' || Q2 != null || Q2 != 'Error(86119X5228X47098)'){ Cost = (38 * Q2); } else if (Q3 == '10% discount for a 1 years subscription is £24.30 (ROW) PROMO- ENG25' && Q3 != '' || Q3 != null && Q2 != ''|| Q2 != null || Q2 != 'Error(86119X5228X47098)'){ Cost = (24.30 * Q2); } else if (Q3 == '10% discount for a 2 years subscription is £33.75 (UK) + a free Calendar PROMO- ENG25' && Q3 != '' || Q3 != null && Q2 != '' || Q2 != null || Q2 != 'Error(86119X5228X47098)'){ Cost = (33.75 * Q2); } else if (Q3 == '10% discount for a 2 years subscription is £45.90 (ROW)' && Q3 != '' || Q3 != null && Q2 != ''|| Q2 != null || Q2 != 'Error(86119X5228X47098)'){ Cost = (45.90 * Q2); } else { Cost = (17.82 * Q2); } var Q1 = {INSERTANS:86119X5228X47079}; var DDCost = '' ; if (Q1 == 'Half price direct debit offer £8.50 for the first year and £17 yearly thereafter (UK) PROMO- ENGLA' && Q2 != '' || Q2 != null || Q2 != 'Error(86119X5228X47098)'){ DDCost = (8.50 * Q2); } else if (Q1 == 'Half price direct debit offer Overseas £12.50 for the first year and £25.00 annually thereafter (ROW) PROMO - ENGLA' && Q2 != '' || Q2 != null || Q2 != 'Error(86119X5228X47098)'){ DDCost = (12.50 * Q2); } else { DDCost = (2.10 * Q2); } var DDCost = '' ; if ({INSERTANS:86119X5228X47079} == 'Half price direct debit offer £8.50 for the first year and £17 yearly thereafter (UK) PROMO- ENGLA' && {INSERTANS:86119X5228X47098} != '' || {INSERTANS:86119X5228X47098} != null || {INSERTANS:86119X5228X47098} != 'Error(86119X5228X47098)'){ DDCost = (8.50 * {INSERTANS:86119X5228X47098}); } else if ({INSERTANS:86119X5228X47079} == 'Half price direct debit offer Overseas £12.50 for the first year and £25.00 annually thereafter (ROW) PROMO - ENGLA' && {INSERTANS:86119X5228X47098} != '' || {INSERTANS:86119X5228X47098} != null || {INSERTANS:86119X5228X47098} != 'Error(86119X5228X47098)'){ DDCost = (12.50 * {INSERTANS:86119X5228X47098}); } else { DDCost = (2.10 * {INSERTANS:86119X5228X47098}); } var Direct_Debit_Cost = document.createTextNode(DDCost); var Pre_pay_Cost = document.createTextNode(Cost); }); </script>
Last edit: 6 years 2 weeks ago by DenisChenu. Reason: [code]
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 12874
- Thank you received: 2369
6 years 2 weeks ago #149336
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Javascript to show calculations based on 2 question
Hi,
Better to learn with good source
- manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascript
- api.jquery.com/
Better to learn with good source
- manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascript
- api.jquery.com/
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.