I have to create a text box in xhtml which displays the current date. The current date is produced by using javascript.
How do i do that? Do i create a function and call it? or do I do something else.
Thank You.
display current date in javascript, how to display current date in javascript
{ 1 comment… read it below or add one }
<html>
<head>
<title>test</title>
<script language="javascript"
type="text/javascript">
function showDate() {
document
.getElementById("txtDate")
.value = Date();
}
</script>
</head>
<body onload="showDate()">
<input id="txtDate" type="text" />
</body>
</html>
You must log in to post a comment.