Reply To: Conditional logic based on selected day

Home Forums Quform WordPress Conditional logic based on selected day Reply To: Conditional logic based on selected day

#30997
dexter303
Participant

Hi,

just want to share what I found in the forum. I changed the dropdown to a timepicker


jQuery(function ($) {
var datepicker = $('.quform-field-1_6').data('kendoDatePicker'),
timepicker = $('.quform-field-1_15').data('kendoTimePicker');

if (window.kendo && datepicker && timepicker) {
datepicker.setOptions({
change: function () {
var date = datepicker.value();

if (date) {
var dayOfWeek = date.getDay(),
times = [];

if (dayOfWeek === 2 || dayOfWeek === 3 || dayOfWeek === 4) {
// Sun
times = ['02:00'];
} else {
// Mon
times = ['02:00', '20:00', '21:00'];
}

var dates = [],
i = 0,
length = times.length,
d;

for (; i < length; i++) {
d = kendo.parseDate(times[i]);

if (d instanceof Date) {
dates.push(d);
}
}

timepicker.setOptions({ dates: dates });
}
},
});
}
});

This solved my problem.

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy