首先,比较两段代码:
1.<html>
<head>
<script type="text/javascript" src="date.js">   //date.js为一个js编写的时间控件函数文件
</script>
</head><body><table align="center">
<tr><td>
<input type="text" name="test" onfocus="showDiv2(this)">
</td></tr>
</table>
</body>
</html>
2.
<html>
<head>
<script type="text/javascript" src="date.js">
</script>
</head><body>
<table align="center">
<form method="post"><tr><td>        //大家注意,现在我将表格放入form表单中了
<input type="text" name="test" onfocus="showDiv2(this)">
</td></tr>
</form>
</table>
</body>
</html>问题出来了,第一段代码运行正常,在一个文本框中点击后,出来日期,然后点击日期,显示在文本框中。但是第二段代码就出错,点击日期后,不能将日期显示在文本框中,报错错位:'test'未定义。请各位指教!