- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Set conditions with JavaScrip
- Amal121
- Topic Author
- Offline
- New Member
Less
More
6 years 5 months ago #159452
by Amal121
Set conditions with JavaScrip was created by Amal121
Hi
I want to show an Alert message using Javascript ( Alert('message')) Based on some condiotons related to other questions
If i write the conditoions if the relevance box the alert message is always shown. So i need to integrate condtions in the JS code
can i do this? and how?
I want to show an Alert message using Javascript ( Alert('message')) Based on some condiotons related to other questions
If i write the conditoions if the relevance box the alert message is always shown. So i need to integrate condtions in the JS code
can i do this? and how?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
6 years 5 months ago #159467
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Set conditions with JavaScrip
If the JavaScript is in the question source or group description, you can use Expression Manager variables. So, maybe something like this (assuming question code "Q1" has been previously answered):
- manual.limesurvey.org/Expression_Manager#Access_to_Variables
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { if('{Q1}' == 'A1') { alert('Your answer to Q1 was {Q1.shown}'); } }); </script>
- manual.limesurvey.org/Expression_Manager#Access_to_Variables
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: DenisChenu
The topic has been locked.
- Amal121
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
6 years 5 months ago #159601
by Amal121
Replied by Amal121 on topic Set conditions with JavaScrip
Hi
The code is not working i think {Q1.jsName} should be used. In the question source it should be something like
java563728X1027X3453.
The code is not working i think {Q1.jsName} should be used. In the question source it should be something like
java563728X1027X3453.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
6 years 5 months ago #159609
by DenisChenu
Maybe your explanation didn't have detail …
Else {Q1.sgq}
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 Set conditions with JavaScrip
The code work … when loading the page.Amal121 wrote: Hi
The code is not working i think {Q1.jsName} should be used. In the question source it should be something like
java563728X1027X3453.
Maybe your explanation didn't have detail …
Else {Q1.sgq}
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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
6 years 5 months ago #159612
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Set conditions with JavaScrip
That code IS working - sample survey attached.The code is not working
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: DenisChenu
The topic has been locked.