Results 1 to 2 of 2

Thread: Adding days to a date

  1. #1
    Join Date
    Feb 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding days to a date

    Howdy all,

    Does anyone know of a script to add days to a date? For example, in textbox1, I have date value (say - 7/1/2005). In textbox2, I want that date plus seven days to be displayed (7/8/2005) (textbox1 will be different depending on when the user opens the form). I can't seem to figure this one out for the life of me...

    - Isaac

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,939
    Thanks
    43
    Thanked 3,193 Times in 3,156 Posts
    Blog Entries
    12

    Default

    Code:
    <html>
    <head>
    <title>Up Date - Demo</title>
    <script type="text/javascript">
    function upDate(dt1, dt2){
    var aDate=new Date(document.getElementById(dt1).value)
    aDate.setDate(aDate.getDate()+7)
    var aMonth=aDate.getMonth()+1
    var aDay=aDate.getDate()
    var aYear=aDate.getFullYear()
    document.getElementById(dt2).value=aMonth+'/'+aDay+'/'+aYear
    }
    </script>
    </head>
    <body>
    <input type="text" value="12/27/2005" id="dateOne"><br>
    <input type="text" value="" id="dateTwo"><br>
    <input type="button" value="UpDate" onclick="upDate('dateOne', 'dateTwo');"><br>
    </body>
    </html>
    Last edited by jscheuer1; 07-22-2005 at 03:34 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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