<body>
<!-- 以下为三个简单的form表单 -->
<form action="x" name="form1" >
<input type="text" name="username" value="zhangsan" />
<input type="text" name="address" value="beijing" />
</form>
<form action="x" name="form2" >
</form>
<form action="x" name="form3" >
</form>
</body>
//---------------------------------------------------------------
<script type="text/javascript">
$(function(){
var thisForm = document.forms['form1']; //获取name为form1的form表单
//或者
//var thisForm = document.forms[0]; //获取第一个form表单
console.info(thisForm.username.value); //输出表单name属性值为form1的 username的值
console.info(thisForm.address.value);
document.forms[0].submit(); //表单提交
})
</script>
网友评论