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

Total javascript newbie here, I need to load current date in textbox

Status
Not open for further replies.

Maim

Programmer
Jun 25, 1999
106
CA
I need a function that enters the current date into a textbox when the page loads, but as I hardly know how to implement javascript into html I need a little help with this.

I've found a few examples of getting the date at a few sites, but no example of how to insert this date into a text box when the page loads...

<script LANGUAGE=&quot;JavaScript&quot;>
<!--
showDate()
{
var currentDate = new Date();
return currentDate;
}
-->
</script>

So from my html, I have this in there...
<input name=&quot;E_CreationDate&quot; size=&quot;10&quot; value=&quot;showDate()&quot;>

but all this does is place &quot;showDate()&quot; in the textbox.

What am I missing here? Is this function gonna work? Am I trying to call the function incorrectly?

Thanks for the help :)
 
value=&quot;javascript:showDate();&quot;
or
value=&quot;javascript:newDate();&quot;

and if none of those works,
<script LANGUAGE=&quot;JavaScript&quot;>
<!--
showDate()
{
var currentDate = new Date();
document.all.the_name_of_the_form.E_CreationDate.value=currentDate
}
-->
</script>
AND
<input name=&quot;E_CreationDate&quot; size=&quot;10&quot;>

(this is ie only tho)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top