SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Set Current Calendar Date

    Does anyone have a bit of code that will set the current date (mm/dd/yyyy) in a text field box and then have a second text box autofill with a date two days later? I've been trying to find one with no avail.

    THANKS!!

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try out this:
    Code:
    var mydt = new Date;
    var month = mydt.getMonth();
    var day = mydt.getDate();
    var year = mydt.getFullYear();
    var fulldate = month + '/' + day + '/' + year;
    document.formname.txtdate.value = fulldate;
    Do you mean that?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks rajug, I'll give it a try. It doesn't look like this code will allow for a secondary box to autofill with a date two days later than the current. Can you modify this code to add a secondary var to include the day two days later?

    Hhhhmmm, I'm thinking now that you would have include some sort of script to figure out which months have 28,29,30 & 31 days. Is this complicated?


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
  •