<form action="http://localhost/action1.jsp" name="outer" onsubmit="window.frames['ccgp'].document.outer.submit()">
<input type=text name="title" value="">
</form><iframe name="ccgp" style="display:none" src="iframe.jsp" target="_blank">
<form action="http://localhost/action2.jsp" name="outer">
<input type=hidden name="title" value="">
</form>
</iframe>
</html>
<input type=text name="title" value="">
</form><iframe name="ccgp" style="display:none" src="iframe.jsp" target="_blank">
<form action="http://localhost/action2.jsp" name="outer">
<input type=hidden name="title" value="">
</form>
</iframe>
</html>
1、分别给两个form不同的命名
2、提交的时候使用js脚本各自提交
3、参考下面:<form action="http://localhost/action1.jsp" name="outer">
<input type=text name="title" value="">
<input type=button name='outerSubmit' onclick='document.all.outer.submit();'>
</form><iframe id="ccgp" style="display:block" src="">
<form action="http://localhost/action2.jsp" name="inner">
<input type=hidden name="title" value="">
<input type=button name='innerSubmit' onclick='document.all.inner.submit();'>
</form>
</iframe>
</html>
<form action="http://localhost/action1.jsp" name="outer" onsubmit="fun()">
<input type=text name="title" value="">
</form>
<iframe id="ccgp" style="display:none">
<form action="http://localhost/action2.jsp" name="inner">
<input type=hidden name="title" value="">
</form>
</iframe>
</html>
其中fun()这个方法应该怎样写呢?
window.frames['ccgp'].document.outer.submit();
}
window.frames['ccgp'].document.outer.submit();
}
function fun(){
window.frames['ccgp'].document.title.value=window.document.all.title.value;
...//此处可以添加提交其它表单而不能是外部的outer,只是fun()是你的外部表单outer的onsubmit触发提交因此你不可以在这里再次提交该表单
window.frames['ccgp'].document.outer.submit();
}
奇怪!我用您的方法就是得不到iframe中的表单对象
function fun(){
window.frames['ccgp'].document.inner.elements[ "title "].value=document.outer.elements[ "title "].value;///////////这行就报错了
window.frames['ccgp'].document.inner.submit();
document.outer.submit();
}
不要用title等关键字
iframe的name不是id
[ "title "]里面有空格
1.htm
<body>
<form name=a action=http://community.csdn.net/ target=_blank>
<input type=submit onclick="window.frames['c'].document.b.submit()">
</form>
<br>
<iframe name=c src="2.htm"></iframe>
</body>2.htm
<body>
<form name=b action="http://news.sina.com.cn" target=_blank>
<input value="ok">
</form>
</body>