I'm working on a survey where I ask parents for their baby's birthdate and then want to display different questions based on their baby's age in months. I read many threads regarding this issue but still didn't manage to make this thing work.
Here is what I've done so far:
1. create this survey flow with an empty 'age' embedded data at the beginning of the survey:
2. Add these scripts to the header of the survey:
3. Add this code to the DOB question to create a Flatpick question that supposes to calculate the age in months and then insert it into the embedded data:
jQuery("#"+this.questionId+" .InputText").flatpickr({enableTime: false, altInput: true, altFormat: "d/m/Y ", dateFormat: "d/m/Y ", time_24hr: false});
var age = moment().diff(moment(jQuery("#"+this.questionId+" .InputText").val()), 'months');
Qualtrics.SurveyEngine.setEmbeddedData('age', age);
4. Add display logic to the last question.
But from what I see, the code just doesn't work. The embedded data stays empty no matter what I enter to the DOB question.
You can see this demo survey live here:
https://bgu.qualtrics.com/jfe/form/SV_3fs4Rf5i60XkNg2
What am I missing?
Thank you
Calculation of age for display logic
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
