获得表单的名字 [有点难]
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>
<head>
<title> New Document </title>
<meta name= "Generator " content= "EditPlus ">
<meta name= "Author " content= " ">
<meta name= "Keywords " content= " ">
<meta name= "Description " content= " ">
<script language= "javascript1.2 " type= "text/javascript ">
function test2(){
//获得form表单的name:test值 现在是表单的name和input中有个name= "name "
}
</script>
</head>
<body>
<form name= "test " id= "t ">
<input name= "name " type= "text ">
<input type= "button " onClick= "javascript:test2(); " name= "tttt " value= "button "/>
</form>
</body>
</html>
------解决方案--------------------function test2(){
var attributes=document.getElementsByTagName( "form ")[0].attributes;
for (var i = 0; i < attributes.length; i++){
if(attributes[i].nodeName== "name ") alert(attributes[i].nodeValue);
}
}