Conditional logic based on selected day

Home Forums Quform WordPress Conditional logic based on selected day

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30992
    dexter303
    Participant

    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 5 months ago by dexter303.
    #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.

    #31000
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy