Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display a date in text field when page loads

Status
Not open for further replies.

pugs421

Technical User
Nov 25, 2002
114
US
I know how to do this with php, but at work I'm limited to only using javascript. All I want is to echo the current date as the value of a text field.

In other words when the page loads, the current date should be displayed in the text field.

Can someone point me in the right direction?

Thanks
 
In your body tag:

<BODY onload='showDate()'>
...

In your JavaScript:

Code:
function showDate()
{
 formName.textAreaName.value = new Date();
}

If you don't like the format of the Date when it loads, save it to a var first, do some simple string manipulation, then set the textarea value to the final string.

'hope this helps.

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top