从日期选择器获取工作日,然后显示/隐藏课程

时间:2014-12-24 23:33:40

标签: javascript

让我们说餐厅只在周六和周日吃早午餐,周五和周六营业。对于预订表格,我希望它显示/隐藏时间选项,具体取决于星期几。我发现这个脚本可以获取星期几,但我需要帮助条件语句来选择类和onchange事件。我为Sat& amp;创造了一个“早午餐”课程。星期五太阳和班级“开放”&星期六

<script>
$( "#date" ).datepicker({
    'dateFormat':'yy-mm-dd',
    onSelect: function(dateText){
        var seldate = $(this).datepicker('getDate');
        seldate = seldate.toDateString();
        seldate = seldate.split(' ');
        var weekday=new Array();
            weekday['Mon']="Monday";
            weekday['Tue']="Tuesday";
            weekday['Wed']="Wednesday";
            weekday['Thu']="Thursday";
            weekday['Fri']="Friday";
            weekday['Sat']="Saturday";
            weekday['Sun']="Sunday";
        var dayOfWeek = weekday[seldate[0]];

    }
});
</script>

<input name="date" id="date" value="" data-gdatetimepicker-format="m/d/Y" type="text" data-fieldtype="gdatetimepicker" data-start_view="d" />

<label>Time:</label>
<select name="time" id="time">
    <option value="11:00 AM" class="brunch">11:00 AM</option>
    <option value="4:00 PM">4:00 PM</option>
    <option value="11:00 PM" class="frisat">11:00 PM</option>
</select>

0 个答案:

没有答案