1个回答
展开全部
可以试试这个办法,将两个表单分开,代码如下
<!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="">
</HEAD>
<script>
function checkUser(){
var formObj = document.forms[0];
formObj.method="post";
formObj.action=".....url........";
//提交A表单
formObj.submit();
}
function checkAll(){
var formObj1 = document.forms[0];
var formObj2 = document.forms[1];
formObj2.elements["userName"].value = formObj1.elements["userName"].value;
formObj2.method="post";
formObj2.action=".....url........";
//提交B表单
formObj2.submit();
}
</script>
<BODY>
<!-- A表单 -->
<form>
<input type="text" name="userName">
<input type="button" onclick="checkUser();" value="提交A表单">
</form>
<!-- B表单 -->
<form>
<!-- 如果全部提交时想取得A表单中的值,放一个隐藏控件取值 -->
<input type="hidden" name="userName">
<input type="text" name="passwd">
<input type="text" name="passwds">
<input type="button" value="提交B表单" onclick="checkAll();">
</form>
</BODY>
</HTML>
<!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="">
</HEAD>
<script>
function checkUser(){
var formObj = document.forms[0];
formObj.method="post";
formObj.action=".....url........";
//提交A表单
formObj.submit();
}
function checkAll(){
var formObj1 = document.forms[0];
var formObj2 = document.forms[1];
formObj2.elements["userName"].value = formObj1.elements["userName"].value;
formObj2.method="post";
formObj2.action=".....url........";
//提交B表单
formObj2.submit();
}
</script>
<BODY>
<!-- A表单 -->
<form>
<input type="text" name="userName">
<input type="button" onclick="checkUser();" value="提交A表单">
</form>
<!-- B表单 -->
<form>
<!-- 如果全部提交时想取得A表单中的值,放一个隐藏控件取值 -->
<input type="hidden" name="userName">
<input type="text" name="passwd">
<input type="text" name="passwds">
<input type="button" value="提交B表单" onclick="checkAll();">
</form>
</BODY>
</HTML>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询