<html>
<head>
<title> test </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
</head>
<body bgcolor= "#FFFFFF " text= "#000000 ">
<form name= "form1 " id="form1" method= "post " action= " " >
<p>
<input type= "text " name= "textfield" value="aaaaa"/>
<input type= "text " name= "textfield1" value="bbbbb"/>
</p>
</form>
<input type= "button " name= "Button " value= "Button " οnclick= "test(); "/>
</body>
<script type="text/javascript">
function test()
{
var form1 = document.getElementById("form1");
for(i=0;i <form1.elements.length;i++)
{
var e = document.form1.elements[i];
alert(e.name+"\t"+e.value);
}
}
</script>
</html>
js循环获得form的值
最新推荐文章于 2022-04-21 14:45:28 发布