date time

G

Guest

How do I have the current date / time appear in a field
for a form to be sent to a data base??
 
K

Kevin Spencer

In ASP?

<input type="text" name="whatever" id="whatever" size="20" value="<%=Now%>">

In JavaScript?

<script type="text/javascript"><!--
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

document.getElementById("whatever").value = day + "/" + month + "/" +
year;
// --></script>
<input type="text" name="whatever" id="whatever" size="20">

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top