为了方便客户发布信息,我在一个页面上同时展现了两个表单。当客户填写信息后,只按一个按钮,先完成注册,紧接着完成信息发布。
  这样要求实现:一个按钮,先激活bb框架下的frmAddNew1表单数据检查(onSubmit="return checkform()),然后再激活aa框架下的表单数据检查(onSubmit="return checkValue())。两个表单数据检查都通过后,再提交。
  我的代码是:<script language="JavaScript" type="text/JavaScript">
function   go(){                                                                   
document.aa.frmAddNew.submit() 

</script><iframe  frameborder="1" height="0" width="760">
 <iframe frameBorder=0  marginHeight=0  marginWidth=0  scrolling="no"  src="../include/aa.asp" name="aa" id="aa" style="width: 720px;height:165%"> </iframe>
  <iframe frameBorder=0  marginHeight=0  marginWidth=0  scrolling="no"  src="../include/bb.asp"  name="bb"  id ="bb" style="width: 740px;height:150%"> </iframe> 
</iframe>其中,aa.asp代码:
<form   name="frmAddNew" method="post"  action=aa_xjxj.asp  enctype="multipart/form-data" onSubmit="return checkValue()" > 
      <input   type=text> 
      <input   type=button name="btnPubs" value="发布信息">
    </form> bb.asp 代码:
<body  onunload=go()> 
<form   name="frmAddNew1" method="post"  action=bb_xjxj.asp  onSubmit="return checkform()"> 
        <input   type=text> 
        <input   type=button  name="btnPubs" value="发布信息">
    </form> 
</body>
bb_xjxj.asp  的代码为:
<%Response.Write "<script>alert('您已经简单注册。您的用户名:"&UserName&" 密码:123456');parent.go()</script>"%>

解决方案 »

  1.   

    如果要两次检查且不刷新页面的话, 用ajax. 
    流程:
    验证表单1 -- 服务端返回 -- 判断是否验证表单2 -- 是, 继续验证/否, return -- 验证表单2 -- 服务端返回 -- 判断是否都通过 -- 是, go()/ 否, 提示, return
      

  2.   

    我没有测试,function checkValue(){
    var aa = document.getElementById("aa").value();
    var bb_form = window.parent.bb.frmAddNew1;
    var bb = bb_form.bb.value;
    if(aa!='' && bb!=''){
    frmAddNew.submit();
    bb_form.submit();
    }
    }
    这是我的思路