JAVA / jQuery

【WordPress / jQuery】選択する曜日によって、選択可能な時間テーブルが切り替わるお問い合わせフォーム【MW WP FORM】

HTML

[mwform_datepicker name="calendar01" class="input_select datepicker01" js='"minDate": 0' size="30" js="dateFormat: 'm月d日',"]

[mwform_select name="hour01-1" class="input_select input_select01" children="1:--,2:9:30,3:9:45,4:10:00,5:10:15,6:10:30,7:10:45,8:11:00,9:11:15,10:11:30,11:11:45,12:12:00,13:12:15,14:12:30,15:12:45,16:13:00,17:13:15,18:13:30,19:13:45,20:14:00,21:14:15,22:14:30,23:14:45,24:15:00,25:15:15,26:15:30,27:15:45,28:16:00,29:16:15,30:16:30,31:16:45,32:17:00,33:17:15,34:17:30,35:17:45,36:18:00,37:18:15,38:18:30,39:18:45,40:19:00,41:19:15,42:19:30,43:19:45,44:20:00"]

[mwform_select name="hour01-2" class="input_select input_select01" children="1:--,2:9:30,3:9:45,4:10:00,5:10:15,6:10:30,7:10:45,8:11:00,9:11:15,10:11:30,11:11:45,12:12:00,13:12:15,14:12:30,15:12:45,16:13:00,17:13:15,18:13:30,19:13:45,20:14:00,21:14:15,22:14:30,23:14:45,24:15:00,25:15:15,26:15:30,27:15:45,28:16:00,29:16:15,30:16:30,31:16:45,32:17:00,33:17:15,34:17:30,35:17:45,36:18:00,37:18:15,38:18:30,39:18:45,40:19:00,41:19:15,42:19:30,43:19:45,44:20:00"]

 

jQuery

<script>
jQuery(function($) {
    $('.datepicker01').datepicker().off("change");
    $(".datepicker01").datepicker().on("change", function(e) {
        var fDate = $('.datepicker01').datepicker('getDate');
        if (fDate !== null) {
            fDate instanceof Date;
            var youbi = fDate.getDay();
            if (youbi == 6 || youbi == 0) {
                $(function() {
                    $('.input_select01').children('[value=1]').remove();
                    $('.input_select01').children('[value=37]').remove();
                    $('.input_select01').children('[value=38]').remove();
                    $('.input_select01').children('[value=39]').remove();
                    $('.input_select01').children('[value=40]').remove();
                    $('.input_select01').children('[value=41]').remove();
                    $('.input_select01').children('[value=42]').remove();
                    $('.input_select01').children('[value=43]').remove();
                    $('.input_select01').children('[value=44]').remove();
                });
                if ($(".input_select01 option[value='2']").length == 0) {
                    $('.input_select01').prepend($('<option>').html('10:15').val('5'));
                    $('.input_select01').prepend($('<option>').html('10:00').val('4'));
                    $('.input_select01').prepend($('<option>').html('09:45').val('3'));
                    $('.input_select01').prepend($('<option>').html('09:30').val('2'));
                    return false;
                }
                return false;
            } else if (youbi == 1 || youbi == 2 || youbi == 3 || youbi == 4 || youbi == 5) {
                $(function() {
                    $('.input_select01').children('[value=1]').remove();
                    $('.input_select01').children('[value=2]').remove();
                    $('.input_select01').children('[value=3]').remove();
                    $('.input_select01').children('[value=4]').remove();
                    $('.input_select01').children('[value=5]').remove();
                    if ($(".input_select01 option[value='37']").length == 0) {
                        $('.input_select01').append($('<option>').html('18:15').val('37'));
                        $('.input_select01').append($('<option>').html('18:30').val('38'));
                        $('.input_select01').append($('<option>').html('18:45').val('39'));
                        $('.input_select01').append($('<option>').html('19:00').val('40'));
                        $('.input_select01').append($('<option>').html('19:15').val('41'));
                        $('.input_select01').append($('<option>').html('19:30').val('42'));
                        $('.input_select01').append($('<option>').html('19:45').val('43'));
                        $('.input_select01').append($('<option>').html('20:00').val('44'));
                        return false;
                    }
                });
                return false;
            };
        };
    });
});
                    </script>