Hello,
I have a question which is supposed to get participants familiar with a task they have to solve later. The question is a text entry, and they can introduce different numerical values and see how that dynamically changes a result.
I would like to count how many attempts at filling in the text entry box participants make. For now, I would also like to display this number on the same page using html (later I will save it as embedded data, the html is just for me to check whether the value updates as it should).
I came up with the following, which does not work:
In JavaScript, in addOnReady:
var counter = 0;
jQuery("#"+this.questionId+" .InputText").bind('input', function() {
counter++;
});
document.getElementById("counter").innerHTML = counter;
In the HTML of the question, I have the following--before any input, the value of "counter" is -1:
-1
Best answer by maruiu
View original