jsPsychSurveyHtmlForm (Debugging) #3203
-
Hello everyone, I am new to jsPsych and run into a problem while coding a simple online questionnaire.
I would be very thankful for any help or ideas how to solve this problem. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Let's see what the problem is. The console indicates that an error var leftInput = jsPsych.data.get().select('response').values[0]['L' + (index)].length; Now, as your var leftInput = jsPsych.data.get().select('response').values[index - 1]['L' + (index)].length;
var rightInput = jsPsych.data.get().select('response').values[index - 1]['R' + (index)].length; But there is also a better way of doing this. var leftInput = data.response['L' + index].length;
var rightInput = data.response['R' + index].length; |
Beta Was this translation helpful? Give feedback.
Let's see what the problem is. The console indicates that an error
main.js:19 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
. The code on that line is:Now, as your
name
property in the html string changes asindex
increments, so that it isL1
in the first trial,L2
in the second, andL3
in the third. However, in the second trial, you are still usingjsPsych.data.get().select('response').values[0]
, which gets the data from the first trial. Naturally, there is onlyL1
and notL2
, causing the error. So the correct way is modifying lines 19 and 20: