I'm suddenly having trouble with several survey questions where I elicit participants' confidence intervals around a previous answer.
For example, in Q102 I ask participants to provide me a number. Q103 should autopopulate into its second blank from the previous question's answer Q102 (). Participants should arrive at Q103 with that second blank already filled in with their previous answer. They should then be able to enter a value in the first blank of Q103 and see the range they've created around their guess in Q102 in the third and fourth blanks.
This was working well when I previewed the survey in the past, but now the second blank in Q103 is no longer populating and thus the whole question is not working properly. Is there something wrong with the underlying javascript in Q103 or Q104? Or has something else about the platform changed? Copying in the text for Q102 and the javascript for Q103 and Q104 below:
Q102: How many questions out of 50 do you think they answered correctly?
Q103 Text: We will now ask you to report your confidence interval around your guess of ${q://QID102/ChoiceNumericEntryValue/1}. Edit the first box below until it reflects a range within which you are very confident the true average score falls:
I am very certain (95% sure) that the true average number of questions answered correctly is within:
Q103 Javascript:
Qualtrics.SurveyEngine.addOnload(function()
{
document.getElementById("QR~QID103~2").disabled = true;
document.getElementById("QR~QID103~3").disabled = true;
document.getElementById("QR~QID103~4").disabled = true;
var val="${q://QID102/ChoiceNumericEntryValue/1}";
document.getElementById("QR~QID103~2").value = val;
setInterval(function(){
var val_1=Number(Number(document.getElementById("QR~QID103~1").value).toFixed(1));
var val_2=Number(Number(document.getElementById("QR~QID103~2").value).toFixed(1));
var val_3=Number(Number(val_2-val_1).toFixed(1));
var val_4=Number(Number(val_1+val_2).toFixed(1));
document.getElementById("QR~QID103~3").value=val_3;
document.getElementById("QR~QID103~4").value=val_4;
}, 100);
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Q104 Javascript:
Qualtrics.SurveyEngine.addOnload(function()
{
setInterval(function(){
var val_main="${q://QID102/ChoiceNumericEntryValue/1}";
jQuery("#QID104").hide();
var val_1=parseInt(document.getElementById("QR~QID103~1").value);
if(val_main<26 && val_1<=val_main)
{
document.getElementById("QR~QID104").value=1;
}
else if(val_main>25 && val_1<=50-val_main)
{
document.getElementById("QR~QID104").value=1;
}
else
{
document.getElementById("QR~QID104").value=0;
}
}, 100);
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Page 1 / 1
Hmm, the scripting you've done is quite complex, obviously. Seems like you only need a nudge in the right direction I would suggest adding the line
debugger;
to the top of your script. This will let you step through the code when the script runs in your browser window and truly debug it. It's a great little tidbit I was only recently turned on to, but it will let you see if the value is being set and wiped out at some point in the code.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.