Need some help with syntax for getting the survey question/answer element

Mehr
1 Monat 2 Wochen her - 1 Monat 2 Wochen her #188409 von 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.
<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
Letzte Änderung: 1 Monat 2 Wochen her von lintu.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
1 Monat 2 Wochen her #188411 von DenisChenu
In template ???
document.getElementById("answer{SID}X{GID}X{QID}SQ001_1-2").checked = true;
{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 …

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 .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her #188430 von lintu
Yes, it's in the survey question template (now called theme in V3.x). Sample sample lss attached.

Thanks for your response.
Anhänge:

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her #188440 von lintu
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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her #188441 von DenisChenu
Don't do this in the theme : it's related to a specific question : right ?

Use www.limesurvey.org/limestore/extensionde...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 .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her #188485 von lintu
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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 2 Wochen her #188490 von DenisChenu
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 …

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 .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha