Date Range Picker (JavaScript)

Date Range Picker (JavaScript)
Hello:
I am trying to add a calendar that allows a customer to choose a range of dates. I found one that was developed by Andrew Petrus using JavaScript (https://medium.com/@ipeat/utilizing-date-range-picker-for-qualtrics-date-selection-ac49fb128765). It works fine except when I select the dates, the calendar/text box disappears on the computer preview, but not the Smartphone preview. Has anyone successfully added a date range calendar either using Andrew's method or another? Thanks in advance for any help/leads.
Paul
Best Answers
-
TomG Raleigh, NC Wizard ✭✭✭✭✭
@esegui said:
coding is not my forte. In the look and feel advanced, I inserted this for jquery and flatpickr
var $j = jQuery.noConflict();then in the JS oiption in the question
flatpickr();obviously, I'm doing something worng
Thanks for your help
EmmanuelYes, you are. No need to load jQuery (Qualtrics already loads it), so your look & feel header is just:
<link href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
Then in your question, you need to attach flatpickr to a text input:
jQuery("#"+this.questionId+" .InputText").flatpickr();
1
Answers
Thanks, Tom! I will take a look.
coding is not my forte. In the look and feel advanced, I inserted this for jquery and flatpickr
var $j = jQuery.noConflict();
then in the JS oiption in the question
flatpickr();
obviously, I'm doing something worng
Thanks for your help
Emmanuel
thanks a lot
I have a simple but powerful improvement to the calendar code that's described here. Basically, qualtrics now provides a calendar picker example question that you can import via Qualtrics Library > Survey Questions > Demographics > Calendar & Date > "Enter a date:". See video:
This however provides a very bulky calendar that takes up alot of room. What i've done is modified the code so that the calendar is hidden and only toggles when you click on the input field and after selecting the date it will again toggle hide.
Simply add the following code to the html view of your input text question type.
Then in add the following Javascript to your question within Qualtrics.SurveyEngine.addOnload(function(){
});