0 votes
in SoSci Survey (English) by s124928 (130 points)


I've been trying to implement more than one filter question on a single page of a questionnaire, but as soon as I add another text element (code), the prior seems to stop working.

For example, let's imagine I have a questionnaire with 10 items and I put a condition that if a subject answers with "Yes" on a question no.3, then he gets another question (no.4), which he wouldn't get if he'd answered with "No" on a question no.3. This works okay.

But when I make a new text element and add this code to the questions no.6 and no.7, it works well with these questions, but the first code stops working for the transition between questions no.3 and no.4.

And so on. It only seems to be working with the latest addition of condition.

Is it possible to have more than one conditional question on the same page?

Thank you for your time,
Darko S.

1 Answer

+1 vote
by SoSci Survey (311k points)
selected by s124928
Best answer

It is important to understand that several JavaScript codes on the same page share the same namespace.

That means, if you use the functon name toogle() and the variable name question in your first JavaScript, this will be overwritten when using a second JavaScript with the same identifiers.

Solution a) Just change the names in the second JavaScript.

Solution b) Encapsulate the JavaScript in classes so that the variable names are not in the general namespace. That, however, will need some JavaScript coding experience.

by s124928 (130 points)
Thank you very much, I've succeeded.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen

Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question