I am trying to define a variable 'res' which will contain the value of the participant's response to a question. I have the following code which is working fine.
var res =Number(document.getElementById('QR~QID1').value);
However, I don't want to insert the question id manually for every question, but have the code directly pull the question id. I know var qid= this.questionId; returns the question id. But I can't seem to figure out the syntax for using this variable directly. Any help will be much appreciated!
Solved
How can I insert defined question id in js?
Best answer by rondev
I have tested below code and working fine
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
var qid = this.questionId;
Qualtrics.SurveyEngine.setEmbeddedData("ED1", Number(document.getElementById('QR~'+qid+'').value));
}
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
