Home › Forums › Quform WordPress › Conditional logic based on selected day
- This topic has 2 replies, 2 voices, and was last updated 3 years, 11 months ago by Ally.
- AuthorPosts
- April 20, 2020 at 12:19 pm #30992dexter303Participant
Hi,
I have a datepicker and a dropdown, how can I change the values of the dropdown based on what day(Monday or Tuesday or Saturday) is selected on the datepicker? Or how to show certain fields based on what day is selected?
Thanks.
- This topic was modified 3 years, 11 months ago by dexter303.
April 20, 2020 at 4:46 pm #30997dexter303ParticipantHi,
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.
April 21, 2020 at 9:43 am #31000AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.