- Posts: 97
- Thank you received: 7
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Need some help with syntax for getting the survey question/answer element
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
4 years 6 months ago - 4 years 6 months ago #188409
by lintu
Need some help with syntax for getting the survey question/answer element was created by lintu
Hello Folks,
I spent several hours trying to figure this out by reading the 3.x manual and going through the forum posts but could not resolve it. I now need your help please...
I upgraded from an older version to Version 3.17.13+190824 and looks like some of the code syntax has changed. As a result, this code that I had within a survey template is broken. I am trying to pre-select a radio button based on a previous selection.
Could someone please help me out with the right syntax for setting the value based on the radio button ID and also for getting the value of a radio button? Thanks
I spent several hours trying to figure this out by reading the 3.x manual and going through the forum posts but could not resolve it. I now need your help please...
I upgraded from an older version to Version 3.17.13+190824 and looks like some of the code syntax has changed. As a result, this code that I had within a survey template is broken. I am trying to pre-select a radio button based on a previous selection.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ //If question G2Q1N has a selection, then pre-select the remaining radio buttons var qc = '{G2Q1N_SQ001}'; if(qc == "A1"){ document.getElementById('answer{SID}X{GID}X{QID}SQ001_1-1').checked = true; }else if(qc == "A2"){ document.getElementById("answer{SID}X{GID}X{QID}SQ001_1-2").checked = true; } else if(qc == "A3"){ document.getElementById("answer{SID}X{GID}X{QID}SQ001_1-3").checked = true; } else if(qc == "A4"){ document.getElementById("answer{SID}X{GID}X{QID}SQ001_1-4").checked = true; } else if(qc == "A5"){ document.getElementById("answer{SID}X{GID}X{QID}SQ001_1-5").checked = true; } }); </script>
Could someone please help me out with the right syntax for setting the value based on the radio button ID and also for getting the value of a radio button? Thanks
Last edit: 4 years 6 months ago by lintu.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
4 years 6 months ago #188411
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 Need some help with syntax for getting the survey question/answer element
In template ???
{SID} {GID} or {QID} can be used only survey : question or help (or
script
)
Else : please send a sample lss else we can not know what broken exactly …
Code:
document.getElementById("answer{SID}X{GID}X{QID}SQ001_1-2").checked = true;
Else : please send a sample lss else we can not know what broken exactly …
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.
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 97
- Thank you received: 7
4 years 6 months ago #188430
by lintu
Replied by lintu on topic Need some help with syntax for getting the survey question/answer element
Yes, it's in the survey question template (now called theme in V3.x). Sample sample lss attached.
Thanks for your response.
Thanks for your response.
Attachments:
The topic has been locked.
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 97
- Thank you received: 7
4 years 6 months ago #188440
by lintu
Replied by lintu on topic Need some help with syntax for getting the survey question/answer element
Can someone help me on what the new tags should be on v3.x? The survey that I have in production is not fully functional until I resolve this issue.
Thanks
Thanks
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
4 years 6 months ago #188441
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 Need some help with syntax for getting the survey question/answer element
Don't do this in the theme : it's related to a specific question : right ?
Use account.limesurvey.org/limestore/extensi...ascript-in-questions it's done for this.
Use account.limesurvey.org/limestore/extensi...ascript-in-questions it's done for this.
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.
- lintu
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 97
- Thank you received: 7
4 years 6 months ago #188485
by lintu
Replied by lintu on topic Need some help with syntax for getting the survey question/answer element
Hi DenisChenu,
This change applies to over 100+ question, so I need to make the change in the custom theme that I created for this survey. Using your plugin would mean that I would need to add the script to every single question manually.
The script that I had in v2.x works but I believe the code syntax changed in v3.x and broke my script.
This change applies to over 100+ question, so I need to make the change in the custom theme that I created for this survey. Using your plugin would mean that I would need to add the script to every single question manually.
The script that I had in v2.x works but I believe the code syntax changed in v3.x and broke my script.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
4 years 6 months ago #188490
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 Need some help with syntax for getting the survey question/answer element
1. Replace `var qc = '{G2Q1N_SQ001}';` by `var qc = '{{ processString("{G2Q1N_SQ001}",1) }}';`
2. Maybe same for QID etc … (but best is to use {SGQ})
I think you can have question.qid etc ¿ in twig , unsure …
2. Maybe same for QID etc … (but best is to use {SGQ})
I think you can have question.qid etc ¿ in twig , unsure …
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.