I get the above mentioned error (The variable IN01_02 has not been asked on a previous page during this interview.) sometimes when running my code.
The section where this variable is used is below - its part of a larger code, but everything else is working, only the storage of 1 or 0 fails.
// Function to show answer (if question is not displayed i.e. has been activated by keypress)
function showanswer() {
if(frage.style.display == "none") {
answer.style.display = "";
document.getElementById("IN01_02").value = "1"; //1 is cheating
}
else {
document.getElementById("IN01_02").value = "0";
}
}
// Initialization of forwarding
SoSciTools.attachEvent(window, "load", function(evt) {
window.setTimeout(showanswer, 3500);
});
The error is strange for two reasons:
1) The variable IN01 is definitely in the questionnaire, and variable IN01_01 works fine saving
2) The error does not show up in any (to me) predictable manner:
Sometimes, IN01_02 storage works and it does it correctly (putting a 0 or 1), and sometimes, it shows up in the debug with IN01_02=?? which is when I receive the error.
Most of the time, when I close the questionnaire, reopen it, and start debug testing, it works the first time; when I try it again, the second time, I receive the error. Here's the strangest part: when I try to use javascript console (opening it in Firefox), the error does no longer occur at all; IN01_02 stores the values correctly every time.
Some help would be really great, thanks a lot.
//update: changed the code to include the timer