We need a form were we enter a intern's start date and contact info and in the next block we get a timesheet for each week of the internship.
For example if we enter 2-7-2022 for start date. The next page will have
- 2-14-2022
- 2-21-2022
- 2-28-2022
- ..
Start date is a text entry using flatpickr and the code below successfully updates InternWeek1 through the last week populating start with today's date (regardless of what is entered in the Start Date field) correctly adding a week each week, using moment.js. I just can't get anything to populate in theStartDate
Here is my code:
Qualtrics.SurveyEngine.addOnUnload(function()
{
var theStartDate= jQuery("#"+this.questionId+" .InputText").val();
var InternWeek1 = moment(theStartDate).add(1, 'weeks');
Qualtrics.SurveyEngine.setEmbeddedData('InternWeek1', InternWeek1);
var InternWeek2 = moment(InternWeek1).add(1, 'weeks');
Qualtrics.SurveyEngine.setEmbeddedData('InternWeek2', InternWeek2);
var InternWeek3 = moment(InternWeek2).add(1, 'weeks');
Qualtrics.SurveyEngine.setEmbeddedData('InternWeek3', InternWeek3);
//for testing
Qualtrics.SurveyEngine.setEmbeddedData('InternWeek24', theStartDate);
});