Allowing respondents to "undo" entry on TimePicker in a Matrix-type question. | XM Community
Question

Allowing respondents to "undo" entry on TimePicker in a Matrix-type question.


I am using a Matrix-type question for respondents to indicate their upcoming weekly schedule (e.g., what time will you go to work on Monday?). Right now, I am using the 24-hour TimePicker code from Flatpicker (https://flatpickr.js.org/examples/#time-picker). My code works as intended except for one part: If participants are not working on a particular day of the upcoming week, we instruct them to leave the field blank. But with the code, if they click on that day, they aren't able to delete the time that appears in the box. Thus, they will HAVE to input an answer even if they didn't intend to.
Does anyone know of any revisions I could make to my code to either a) allow people to delete times from boxes after already clicking on them, or b) allow people to input a non-time answer to indicate that they do not work on a specific day? Thank you to any insights! I am new to using code in Qualtrics.

Here is my current code for the Matrix question:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("#"+this.questionId+" .InputText").flatpickr({
    enableTime: true, 
    noCalendar: true, 
    defaultTime: "H:i"
    });
});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});


2 replies

Userlevel 5
Badge +13

@cphetmisy You would need to customize the plugin to have a link or button to reset the field and force the field to lose focus (because as long as the field has focus the time picker plugin is going to take over).
Someone else had the same question about the code and the developer did not seem interested in implementing it.
https://github.com/flatpickr/flatpickr/issues/997

@w.patrick.gale Thank you for sharing this link! I was able to see that lots of people have had similar questions but unfortunately I could not find a clear way to edit the code to get it to work.
I am now looking into a solution where I can just input an additional option of "I do not work this day" after all the times listed. For example, instead of having to leave the box blank, there could just be this text within the dropdown menu with all the other times. I am open to any suggestions!

Leave a Reply