I am trying to figure out a way that when a page loads it pulls the date and time into a text box.
Any ideas....
Thanks
Any ideas....
Thanks
<form name="myform"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td> <input type="text" name="thedate" size="11" maxlength="10" style="background:#cccccc; color:#000000; border style:1px solid #666666; text-align:center; font-weight:normal; font-size:12px" > </input> </td> </tr> <tr> <td> <input type="text" name="time" size="11" maxlength="11" style="background:#cccccc; color:#000000; border style:1px solid #666666; text-align:center; font-weight:normal; font-size:12px" > </input> </td> </tr> </table> </form> <script language="javascript"> <!-- function showdate(){ var thedate=new Date(); var mymonth=thedate.getMonth()+1; var mydate=thedate.getDate(); var myyear=thedate.getFullYear(); if(mymonth<10){ mymonth="0"+mymonth; } if(mydate<10){ mydate="0"+mydate; } mynewdate=mymonth+"/"+mydate+"/"+myyear; var thefield=document.myform.thedate; thefield.value=mynewdate; thefield.blur(); setTimeout("showdate()",1000); } showdate() // --> </script> <script> <!-- function showtime(){ var meridian="AM"; var mydate=new Date(); var myhours=mydate.getHours(); var myminutes=mydate.getMinutes(); var myseconds=mydate.getSeconds(); if (myhours>11){ myhours-=12; meridian="PM"; } if(myhours==0){ myhours=12; } if(myminutes<10){ myminutes="0"+myminutes; } if(myseconds<10){ myseconds="0"+myseconds; } mynewtime=myhours+":"+myminutes+":"+myseconds+" "+meridian; var thefield=document.myform.time; thefield.value=mynewtime thefield.blur(); setTimeout("showtime()",1000) } showtime() //--> </script>
Comment