<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>js获取input文本框值的4种方法</title>
</head>


<body>
<FORM NAME="form1">
  姓名:
  <INPUT TYPE="text" NAME="name" value="DoGo">
  <BR>
  电话:
  <INPUT TYPE="text" NAME="tel" value="BB">
  <BR>
</FORM>
<script language="javascript">
    document.writeln(document.forms[0].tel.value);
document.writeln(document.form1.tel.value);
document.writeln(document.forms[0].elements[1].value);
document.writeln(document.form1.elements[1].value);
  </script>
</body>
</html>

本文转载:CSDN博客