无线电选择中重叠时间的问题 [英] Problem with overlapping times in radio selections

查看:71
本文介绍了无线电选择中重叠时间的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有这个代码,感谢有帮助的人,但它没有按预期完全工作。问题是它目前检查日期的完全匹配,但是有些时候彼此重叠并且也应该显示冲突(在发生冲突时背景变为红色)。如您所见,以下日期工程与可靠性的工作重叠于10月30日星期三上午10点至下午12点15分。显然,不能同时在不同的位置。



使用的代码是:



 $( 。time)。change( function (){
var values = $( input.time)。map( function (){
return $( this )。val();
});
values.each(< span class =code-keyword> function (){
var overlap = $( input.time [value =' + + ']);
if (overlap.filter( :checked)。length> 1 ){
overlap.parents( tr)。addClass( red);}
else {
overlap.parents( tr)re​​moveClass( red);
}
})
});





小提琴在这里:http://jsfiddle.net/3VFRt/



我知道需要做什么但我似乎无法掌握如何在jQuery中完成。我认为它需要从列(td)中提取日期数据并查看是否存在时间重叠,如果是,则相应地显示它(css class = red)。基本上脚本需要一些精炼,它将完美地工作。如果有人能帮助我,我会非常感激。在此先感谢。

解决方案

。time )。change( function (){
var values =

input.time)。map( function (){
return


this )。val();
});
values.each( function (){
var overlap =


We have this code, thanks to a helpful person but it does not fully work as expected. The problem is that it currently checks for an exact match of dates, but there are situations of times that overlap one another and that should show a conflict too (background becomes red in case of conflicts). As you can see the following date "Wednesday Oct/30 11:00 AM - 3:15 PM" of Engineering overlaps with both Wednesday Oct/30 10:00 AM - 12:15 PM of Business and Reliability. Obviously one cannot be at the same time at different locations.

The code used is this:

$(".time").change(function() {
        var values = $("input.time").map(function(){
            return $(this).val();
        });
        values.each( function (){
            var overlapping = $("input.time[value='"+ this +"']");
            if (overlapping.filter(":checked").length > 1){                            
                overlapping.parents("tr").addClass("red");}
            else{
                overlapping.parents("tr").removeClass("red");
            }
        })
    });



The fiddle is here: http://jsfiddle.net/3VFRt/

I know what needs to be done but I can't seem to grasp how that is done in jQuery. I am thinking it needs to extract the date data from the columns (td's) and see if there is an overlap in time, if so show it accordingly (css class=red). Basically the script needs some refining and it will work perfectly. If anyone can help me out here I would be very grateful. Thanks in advance.

解决方案

(".time").change(function() { var values =


("input.time").map(function(){ return


(this).val(); }); values.each( function (){ var overlapping =


这篇关于无线电选择中重叠时间的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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