1. 获取表单里的元素值
<form name="myform">
<input type="text" name="mc" />
<input type="text" name="user.name" id="nameId"/>
</form>
获取元素值: 1.document.myform.mc.value
2.document.myform.elements["user.name"].value
2. 改变输入框为只读
document.myform.elements["user.name"].readOnly = true;
3 改变输入框的样式
document.getElementById("nameId").className="inputStyle";
4 显示动态时间
<script language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
document.clock.thetime.value = now.toString();
timerID = setTimeout( "showtime() ",1000);
timerRunning = true;}
</SCRIPT>
<body οnlοad=startclock()>
<form name=clock >
<input name=thetime style= "font-size: 9pt;color:#000000;border:0 " size=100>
</form>
5用jsp实现在线时间功能
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.Date"%>
<% response.setHeader("Refresh","1"); %>
现在时间是:
<%=new Date() %>