1.form 中的嵌套
問題:不認識第一個form,拋出缺少對象。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<script language="javascript">
function test(formName) {
?var theForm = document.getElementById(formName);
?alert(theForm.name);
}
</script>
</head>
<body>
<form name="searchForm">
?<form name="1Form">
?</form>
?<form name="2Form">
?</form>
?<form name="3Form">
?</form>
?
?<input type="button" name="other" value="提交1Form" onClick="test('1Form');" />?????
?<input type="button" name="sub" value="提交2Form" onClick="test('2Form');" />
?<input type="button" name="main" value="提交3Form" onClick="test('3Form');" />
?<input type="button" name="main" value="提交searchForm" onClick="test('searchForm');" />
</form>
</body>
</html>