0 votes
ago in SoSci Survey (English) by s059308 (190 points)

Hi Team,

I have one simple selection type question per survey page. There is one correct answer, and the users have to click "next" before they continue to the next page.
I have 8 answer options, and I need to know which choice options were clicked, before the users settled on a final answer (by clicking next), and how many times these options were clicked.
Example: The correct answer is A. The user has to click a bunch of options (as I have some .js pop-ups, which show some extra info about the respective option) before making a decision. Clicking on that extra info registers a click on the answer option. So, to make a decision, the users might click B, C,D, and F, before choosing A and then clicking "Next". I want to record these B, C,D, and F clicks, and have a count on each, i.e. F was pressed 5 times, D 3 times, etc.
How can I do that?
Thank you in advance.

1 Answer

0 votes
ago by SoSci Survey (332k points)
selected ago by s059308
 
Best answer

I want to record these B, C,D, and F clicks

As you have already worked with JS, it's dtraigt forward: Use JS to write the information into an internal variable that you placed on the page.

If you don't already have triggers for the options being selected, you can use

s2.AB01.getItem(1).addEventListener("click", ...)

where AB01 would be the question ID, and you should run the code only after the page has loaded. You may, of course, also adress the radio inputs directly, using their HTML IDs.

ago by s059308 (190 points)
Hi,
Thank you for your answer. The confusion is where to write that snippet. The html where I call the .js pop-ups is within the text of each answer option. I had to convert the answer optins into product frames, which have different elements. One of these elements is a pic, which on click opens a pop-up. So I am calling the pop-ups within the html, but the pop-ups themselves needed to be on a seperate "text" item on the same page, as this was required by SoSci to run them to begin with. So where should I call the variable and add the trigger? I just noticed that opening the pop-ups also selects the respective answer, so I figured this would be realtively easy to record, I just wonder where
ago by SoSci Survey (332k points)
Usually, you would place the JavaScript code at the end of the page, using a text element formatted as "HTML code".

> I just noticed that opening the pop-ups also selects the respective answer

Depends on how you create the pop-ups. You could as well catch the events via stopPropagation() and preventDefault() so that the option was not selected.

If you have not worked with JS events a lot, you may want to read a few lines about them.
ago by s059308 (190 points)
Thank you,
I have made an internal varible, called DI90, and I have put it on the page within a PhP windoiw with  question('DI90');  , so now I can at least see it in the dataset.
Then I found some old SoSci documentation about recording clicks, and it seems to create some incremental count function, so I adapted it to record clicking on AD15_05a:

<script type="text/javascript">

function counter(varID) {
  return function() {
    var input = document.getElementById(varID);
    var count = parseInt(input.value);
    if (isNaN(count)) {
      count = 0;
    }
    count++;
    input.value = count;
  }
}
 
document.getElementById("AD15_05a").addEventListener("click", counter("DI90_01"));
</script>

However, nothing gets stored in DI90. Can you help?
ago by SoSci Survey (332k points)
Check the browser's JavaScript console please. What does it say?
ago by s059308 (190 points)
edited ago by s059308
8 "invalid or unexpected token" errors, one for each answer option of my selection question.
But this is because I am trying to make SoSci do things it is not made to do. In any case, I am an idiot, I just got it to store the clicks. The code above works, but for some reason had to placed in a seperate file from the other code I used for the pop-ups. Thank you for your time! You were amazing and patient with me.
ago by SoSci Survey (332k points)
You're welcome :)

> I am trying to make SoSci do things it is not made to do

Yeah! Over the years, I learned about some really fascinating tools created with SoSci Survey. Don't worry, I use SoSci for a lot of applications far beyond traditional online surveys myself, so testing out the limits is close to "official" :D

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

...