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

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

问题描述

我正在使用Kelvin Luck的jQuery Date Picker插件( 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天全站免登陆