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

Timestamp 1

Status
Not open for further replies.

Slippenos

MIS
Apr 22, 2005
333
US
I want this timestamp to appear in the textbox when I click the button.

It obviously doesn't work.

Code:
<html>
<body>

<script language = "javascript">
<!--
//------------------------------------------------------

function Stamp( )

	{

	var timeStamp = new Date( );

	// Date

	document.drf.DateSubmit.write( timeStamp.getMonth( ) + 1 )
	document.drf.DateSubmit.write( "/" )
	
	document.drf.DateSubmit.write( timeStamp.getDate( ) )
	document.drf.DateSubmit.write( "/" )
	
	document.drf.DateSubmit.write( timeStamp.getFullYear( ) )
	document.drf.DateSubmit.write( "  " )

	// Time

	document.drf.DateSubmit.write( timeStamp.getHours( ) )
	document.drf.DateSubmit.write(":")

	document.drf.DateSubmit.write( timeStamp.getMinutes( ) )

	}

//------------------------------------------------------ 
//-->
</script>

<form name = "drf">
<input type = "button" onclick = "Stamp();" value = "Click">
&nbsp;
<input type = "text" name = "DateSubmit">
</form>
</body>
</html>
 
Try this:
Code:
function Stamp( ){
  var timeStamp = new Date( );
  var string = "";
  // Date
  string += timeStamp.getMonth( ) + 1;
  string +=  "/";
    
  string += timeStamp.getDate( );
  string +=  "/";
    
  string +=  timeStamp.getFullYear( );
  string +=  " "; 

  // Time

  string +=   timeStamp.getHours( );
  string +=  ":";

  string +=  timeStamp.getMinutes( );
  
  document.forms.drf.elements['DateSubmit'].value = string;

}


[cheers]
Cheers!
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top