Jquery 日期选择器:选择一个日期,自动更新第二个字段 [英] Jquery Date picker: Select one date, automatically update second field

查看:24
本文介绍了Jquery 日期选择器:选择一个日期,自动更新第二个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Kelvin Luck 的 jQuery 日期选择器插件(http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ ) 并需要执行以下操作,也许有人可以帮助我:

I'm using the jQuery Date Picker plugin by Kelvin Luck ( http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ ) and need to do the following, maybe somebody can help me:

在旅游保险网站上,我有两个日期字段,一个用于开始日期,一个用于结束日期.还有第三个字段(选择),用于在几天内选择计划,每个计划都有不同的覆盖范围.这个想法是,如果您选择一个计划,例如,15 天,开始日期为 X,则第二个日期字段将神奇地填充为 X + 15 天的日期.

On a website for travel insurance I have two date fields, one for a start date and one for an end date. There's also a third field (a select) that selects plans, each with a different coverage, in a number of days. The idea would be that if you select a plan for, for example, 15 days, and a start date of X, the second date field would be magically populated with a date of X + 15 days.

事实是,我的 JavaScript 知识并不是你所说的高级.

Thing is, my JavaScript knowledge is not what you would call advanced.

有人对插件有一些经验,或者至少可以给我一些建议吗?

Anybody has some experience with the plugin, or could at least give me some pointers?

非常感谢.

推荐答案

也许这会有所帮助

$(document).ready(function(){    
    $("#date2").datepicker();  
    $("#date1").datepicker({  
        onSelect: function(){  
            var fecha = $(this).datepicker('getDate');  
            $("#date2").datepicker("setDate", new Date(fecha.getTime()));  
            $("#date2").datepicker("setDate", "+15d");  
        }  
    });  
});  

我想这就是你需要的

这篇关于Jquery 日期选择器:选择一个日期,自动更新第二个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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