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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic Date Input.

Status
Not open for further replies.

Giblets

Programmer
Feb 19, 2003
6
GB
Hello,I have the following question;
How would I write a function to allow me to insert the current date into a date field on a form?

I don't have much javascript experience so I'ld be really grateful for some help.

Cheers
Giblets.
 
just use this var datefield=new Date()-it automatically puts todays date into the variable datefield

if you wnat to see the date if you have a textbox
textbox1.text = datefield.Date will show you the date as of now
 
Giblets,

Here is one way to accomplish your request.. This is done clientside.

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Page title</title>
</head>
<body>

<script language=&quot;javascript&quot;>
<!--
var dateit = new Date();
document.write(&quot;<input type=text name='todaysDate' value='&quot; + dateit + &quot; style='font-size:11px'>&quot;)

//-->
</script>

</body>
</html>

Hope this helps.
DougCranston
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top