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
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
