使用datepicker添加当天的天数 [英] Add number of days from current day using datepicker

查看:74
本文介绍了使用datepicker添加当天的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个datepicker文本框(jquery ui)。

req是当我在textbox1上选择特定日期时,另一个文本框会自动填充在textbox1上选择的日期前3天(javascript )。



现在我正在使用以下功能:



I have two datepicker text boxes (jquery ui).
The req is when I select a particular date on textbox1, the other textbox automatically populates 3 days prior to the date selected on textbox1 (javascript).

Right now I am using the below function:

function getdate() {
        var tt = document.getElementById('txtDate').value;
       
        

         date      = new Date(tt);
            next_date = new Date(date.setDate(date.getDate() + 1));
            formatted = padNumber(next_date.getUTCMonth() + 1) + '/' + padNumber(next_date.getUTCDate() + 3) + '/' + next_date.getUTCFullYear()
            document.getElementById('follow_Date').value = formatted;
        }





但是当第30天到来时,它会增加30 + 3并显示33而不是下个月。

请帮忙。 :)



But when the 30th day comes, it adds 30 + 3 and shows 33 instead of going to the next month.
Please help. :)

推荐答案

尝试jQuery:

Try jQuery:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script></script>
 <script>


(document).ready(function(){
(document).ready(function(){


(#datepicker1)。datepicker({
onClose:function(){
var date2 =
( "#datepicker1" ).datepicker({ onClose: function() { var date2 =


这篇关于使用datepicker添加当天的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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