Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adding to dates from input box

    Hil,

    I searched and searched but could not find a idea that can light me. if anyone point me to article or tutorial on this would be appreciated.

    i have found one, and its close to it and need a little tweak to work on second textbox

    Code:
    <script language="JavaScript">
    <!--
    function addDays(myDate, days){
       myDate.setDate(myDate.getDate()+days);
       return myDate;
    }
    
    document.write(addDays(new Date("7/16/2004"),30));
    //--></script>
    i have two input textbox for dates, one is date borrowed
    which from date picker calendar 07/21/2009
    and what i would like to make is the second textbox would be auto compute for X months
    meaning the second input textbox whould display a value = 01/21/2010 if i assign a 6 months variable

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Code:
    function addMonths(myDate,months) {
    myDate.setMonth(myDate.getMonth() + months);
    return myDate;
    }
    
    document.write(addMonths(new Date("7/21/2009"),6));  //  21 January 2010
    It is your responsibility to die() if necessary….. - PHP Manual
    Last edited by Philip M; 07-21-2009 at 10:49 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •