I have looked through many previous answers and have come to the conclusion that I know too little about Javascript so please be patient.
I have found a suggestion to use luxon so have added this to a footer in Look and Feel
<script src="https://cdn.jsdelivr.net/npm/luxon@3/build/global/luxon.min.js"></script>
I have set the following embedded fields at the start:
Age
DateTime
And then after the parent has entered their child’s date of birth (it’s a field with a content check, and has to be DD/MM/YYYY) I have set
BirthDate = ${q://QID1215690757/ChoiceTextEntryValue}
I have looked at this code
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var DateTime = luxon.DateTime;
var birthDate = DateTime.fromFormat(jQuery("#"+this.questionId+" .InputText").val(),"MM/dd/yyyy");
var age = DateTime.now().diff(birthDate, r'months','days']).toObject();
Qualtrics.SurveyEngine.setEmbeddedData('age',age.months);
});
which is from this question
However, I am not sure what I need to do next.
As a test, I tried using just the line
var DateTime = luxon.DateTime;
followed by
Qualtrics.SurveyEngine.setEmbeddedData('DateTime',DateTime);
However, it did not appear when I piped the embedded data into a later question.
I also tried just
Qualtrics.SurveyEngine.addOnload(function()
{
Qualtrics.SurveyEngine.setEmbeddedData( 'DateTime', 18 );
});
But again I just got a blank when I piped this into another question.
Any suggestions?
thanks very much