Click to See Complete Forum and Search --> : pre-populating form fields dynamically


lagbaja
11-29-2002, 02:12 PM
I am trying to pre-populate a form field dynamically, so that the date field and the time field automatically populate with the current date and time. I have been able to do this with static values but would like to be able to do this dynamically. can anyone offer some help?

<td bgcolor="#EFF7DE" >
<font class="medium_bold">Time Received</font></td>
<td class="medium">
<input type="text" class="text_box" size="44" name="recvt" id="recvt" value="3:30 pm"></td>

AdamGundry
11-30-2002, 03:50 AM
You probably want something like this, though I haven't tested it yet:


<body onload="populatefields()">

<input type="text" class="text_box" size="44"
name="recvt" id="recvt"></td>

<script language="javascript">
function populatefields(){
dt = new Date();
recvt.value = dt.getHours + ':' + dt.getMinutes;
}
</script>


Good luck

Adam