<input id=a1>
<script>
var a=new Date()
a1.value=a.getHours()+":"+a.getMinutes()+":"+a.getSeconds()
</script>

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 3</title>
    </head>
    <body >
    <input type="text" name = "aa" value=''></body>
    <script language="javascript">var strdate;
    var date = new Date();
    strdate = date.getYear() +"/"+ (date.getMonth()+1) +"/"+ date.getDate();
    document.all.aa.value=strdate;
    </script></html>
      

  2.   

    看来我还是要写规范一些<input id=a1>
    <script>
    window.onload=function(){
    var a=new Date()
    document.all.a1.value=a.getHours()+":"+a.getMinutes()+":"+a.getSeconds()
    }
    </script>
      

  3.   

    <input id=a1>
    <script>
    window.onload=function(){
    var a=new Date()
    h=a.getHours().toString()
    m=a.getMinutes().toString()
    s=a.getSeconds().toString()
    document.all.a1.value=((h.length==1)?"0"+h:h)+":"+((m.length==1)?"0"+m:m)+":"+((s.length==1)?"0"+s:s)
    }
    </script>
      

  4.   

    <input id=a1>
    <script>
    window.onload=showtime
    function showtime(){
    document.all.a1.value=new Date().toLocaleString(); 
    setTimeout("showtime()",1000)
    }
    </script>