开始和结束时间DropDown。 [英] Start and End Time DropDown.

查看:77
本文介绍了开始和结束时间DropDown。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想为 FromTime ToTime 做两次下拉。



表格上有一个jquery日历,现在我想在下拉菜单上显示早上8点到晚上8点的时间,差异为30分钟。



条件是 FromTime 不应小于 ToTime FromTime 应该从当前时间开始,表示当前日期 09/16/2015 ,当前时间 5pm ,因此用户不应允许选择少于该时间。



我知道它很简单,但我已经完成了第一个条件,但我无法破解第二个条件。有人可以帮忙吗?



以下是我的代码:



Hi All,

I want to make two drop downs for "FromTime" and "ToTime".

I have a jquery calendar on form, Now I want to show the 8am to 8pm timings in both the dropdowns with 30 min difference.

The condition is that "FromTime" should not less than the "ToTime" and FromTime should start from current time on current date means say current date is 09/16/2015 and current time is 5pm so user should not allow to select less than that time.

I know its simple but I have done with first condition but I am unable to crack the second condition. Can anyone help?

Below is my code:

var currentTime = new Date();
    var currenthours = parseFloat(currentTime.getHours());
    

    $("#toCollectionTime").prop("disabled", true);
    
    $("#fromCollectionTime").change(function () {
        $("#toCollectionTime").prop("disabled", false);
        var fromCollectionTime = parseFloat($("#fromCollectionTime :selected").text());
        var toCollectionTime = parseFloat($("#toCollectionTime :selected").text());
        if (fromCollectionTime < currenthours) {
            $("#fromCollectionTime").val(currenthours + ":00");
        }
        if (fromCollectionTime > toCollectionTime) {
            var localFrom = $("#fromCollectionTime :selected").text();
            $("#toCollectionTime").val(localFrom);
        }
    });
    $("#toCollectionTime").change(function () {
        var fromCollectionTime = parseFloat($("#fromCollectionTime :selected").text());
        var toCollectionTime = parseFloat($("#toCollectionTime :selected").text());
        if (toCollectionTime < fromCollectionTime) {
            var localFrom = $("#fromCollectionTime :selected").text();
            $("#toCollectionTime").val(localFrom);
        }
    });





谢谢



Thanks

推荐答案

#toCollectionTime)。prop( 已禁用 true );
("#toCollectionTime").prop("disabled", true);


#fromCollectionTime)。change( function (){
("#fromCollectionTime").change(function () {


#toCollectionTime) .prop( disabled false );
var fromCollectionTime = parseFloat
("#toCollectionTime").prop("disabled", false); var fromCollectionTime = parseFloat(


这篇关于开始和结束时间DropDown。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆