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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation getDate...got it working...one last STEP!

    I need to get the date to write into an Input box in the body of my page.

    I have the date working using the following code:

    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    document.write(month + "/" + day + "/" + year)

    This displays the date on the top of the page. I need it to display the date INTO an INPUT BOX placed in the BODY of my page.

    Any help would be appreciated.

    Thanks.

  • #2
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You use document.getElementById('mydatefield').value= month + "/" + day + "/" + year

    so use <input type=text id="mydatefield" ReadOnly value="" size=10> in your html body.

    tested and working

    btw is there away to use value=getmydate() in the html?
    Or value can not get a return string from a function?
    Last edited by tonyp12; 01-31-2007 at 11:32 PM.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I would have been more consistent in HTML coding

    <input type="text" id="mydatefield" readonly="readonly" value="" size="10">
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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