Solved
How to create variable based on previous response?
I've never used javascript.
I'm going to be doing a lot of display logic based on zipcode. Essentially, I want to take a lot of zipcodes (over 1k) and condense them to a couple dozen.
My plan was to create a hidden question and create some if logic to condense.
So - Q1.4 is where I ask people to enter zipcode
Q72 is a hidden question where I hope to condense the codes. From poking around on here, I've got:
jQuery("#"+this.questionId).hide(); //here's where I'm hiding the question
Which works perfectly... but I haven't been able to just do some simple logic like: if zipcode is '60606' then store '33' into Q72.
It seems like this should be really easy.
Best answer by SaurabhPujare_Ugam
Hey @Dan,
Hope it helps...
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
var tboxID= "QR~"+this.questionId;
var val = document.getElementById(tboxID).value;
Qualtrics.SurveyEngine.setEmbeddedData("Val",val);
if(val==60606)
{
Qualtrics.SurveyEngine.setEmbeddedData("ZipCode",33);
}
});
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.