0 votes
in SoSci Survey (English) by s155876 (140 points)

I would like for the respondents to see a short text (i.e. recommended answer or feedback) if they select a certain answer on a 7-point Likert-scale and give them the opportunity to change their answer. Is this possible?

1 Answer

0 votes
by SoSci Survey (305k points)

Sure, one option to achieve that is documented here:
Immediately Show Questions when a Certain Option is Selected

Just replace "question" by "text", and you can display a message. You colud also use a bit HTML code to place the message closer to the selected option.

by SoSci Survey (305k points)
Okay, we're making progress :) The browser's error console now says:

> Uncaught ReferenceError: question is not defined

That refers to this line:

> question.style.display = "none";

And yes, there is no variable "question", because you named the variable "text", so please change the line as follows:

> text.style.display = "none";

And the other "question" as well, of course.
by s155876 (140 points)
edited by s155876
Unfortunately, still not change :(
Maybe a little more information helps? NU07 is the text I created, which should appear once any button is clicked. The "Darstellung" selected is "Einfacher Text". Is this correct? I also realized the element ID is NU07_media, not NU07_text. But still no change...

All seven options stand for all seven available buttons. There are no other buttons, so providing any answer at all should trigger the dropdown.

This is the new code:
<script type="text/javascript">
<!--
var optionA = document.getElementById("NU06_011");  // NU06_011 is the HTML ID of the selection option "Very unlikely"
var optionB = document.getElementById("NU06_012");  // "Slightly unlikely" option
var optionC = document.getElementById("NU06_013");  // "Unlikely" option
var optionD = document.getElementById("NU06_014");  // "Neutral" option
var optionE = document.getElementById("NU06_015");  // "Likely" option
var optionF = document.getElementById("NU06_016");  // "Slightly likely" option
var optionG = document.getElementById("NU06_017");  // "Likely" option
var text = document.getElementById("NU07_media");  //   HTML ID of the text input
 
function toogle() {
  // the two pipes (||) are a logicial "or"
  // the condition checks: is option A selected or is B selected?
if (optionA.checked || optionB.checked || optionC.checked || optionD.checked || optionE.checked || optionF.checked || optionG.checked) {
    // if any button is clicked, then the question is shown
    // no input ("") uses the default setting (display as usual)
    text.style.display = "";
  } else {
    // question is hidden if the "none" option is selected
    text.style.display = "none";
  }
}
 
// The function should always be executed, if one of the buttons is clicked on
SoSciTools.attachEvent(optionA, "click", toogle);
SoSciTools.attachEvent(optionB, "click", toogle);
SoSciTools.attachEvent(optionC, "click", toogle);
SoSciTools.attachEvent(optionD, "click", toogle);
SoSciTools.attachEvent(optionE, "click", toogle);
SoSciTools.attachEvent(optionF, "click", toogle);
SoSciTools.attachEvent(optionG, "click", toogle);
 
// and the function should also be executed, so that the display at the beginning is correct
// (e.g. hide the text input at the beginning)
toogle();
// -->
</script>

This is what the error console is saying:

Uncaught TypeError: Cannot read property ?act=SczFRN3hnzyCl51b2LBzvLeF:639
'style' of null
    at toogle (?act=SczFRN3hnzyCl51b2LBzvLeF:639)
    at ?act=SczFRN3hnzyCl51b2LBzvLeF:654
by SoSci Survey (305k points)
> The "Darstellung" selected is "Einfacher Text". Is this correct?

When you're using the German GUI, why are you writing in English?

Well, we're getting closer. The "cannot read property" error is hard to understand. In Firefox, it read like:

> Uncaught TypeError: text is null

And it refers to this line:

> text.style.display = "none";

Why that= The variable "text" has been initialized properly. Well, now we're coming the one of the most unnerving aspects of JavaScript: Timing.

It seems like you are running your code, especially

> var text = document.getElementById("NU07_media");

and th toogle() before (!) the text NU07_media has been embedded in the page. You just put the JavaScript above the text.

So what happens? At the time your code rund, there is no element NU07_media  there, yet. The solution is simple: Drag the JavaScript below NU07.
by s155876 (140 points)
> When you're using the German GUI, why are you writing in English?
English is my first language, so I feel more comfortable writing in English :) Sorry if this made things more complicated.

I changed the order and it worked! Thank you so much for your help and support!
by SoSci Survey (305k points)
Good - I was afraid, you were writing in English to comfort us.

You may like to change the GUI language to English in the user account settings. And don't hesitate telling us where the English interface needs improvement ;)

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

...