How to insert the current date in a textfield

Results 1 to 2 of 2

Thread: How to insert the current date in a textfield

  1. #1
    Join Date
    Dec 1969

    Default How to insert the current date in a textfield

    Hello, i am trying to insert the current date in a text field so that i will know when the form is submitted in my database. i used a small javascript code that gets the date but i don't know how to make it the default value of that text field? Can please somebody assist?

  2. #2
    Join Date
    Dec 1969

    Default client-side/server-side

    You would be better off using a server-side solution for this, because different clients might be in different time zones.<BR>on the page that the form submits to, create a VBscript variable:<BR><BR>theDate = Date();<BR><BR>and use theDate as the value you load into your database.<BR><BR>But, if you _really_ want to use client-side, just call a function on the onload event of the body object which sets the text field&#039;s value property to your jscript variable:<BR><BR>&#060;script language="javascript"&#062;<BR>mydatevalue = Date();<BR>function doDate(){<BR> document.theForm.theDate.value = mydatevalue;<BR>}<BR>&#060;/script&#062;<BR>&#060;body onload="doDate();"&#062;<BR>&#060;form method="post" value="somepage.asp" name="theForm"&#062;<BR>&#060;input type="text" value="" name="theDate"&#062;<BR>&#060;/form&#062;<BR>&#060;/body&#062;<BR><BR>~~Chaotix<BR>

Posting Permissions

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