<body>
  <div id="tb_" class="tb_ no-print">
    <ul>
      <li id="tb_1" class="hovertab" onclick="x:HoverLi(1);"> 第一页 </li>
      <li id="tb_2" class="normaltab" onclick="i:HoverLi(2);"> 第二页 </li>
      <li id="tb_3" class="normaltab" onclick="i:HoverLi(3);"> 第三页</li>
      <li id="tb_4" class="normaltab" onclick="i:HoverLi(4);"> 第四页 </li>
      <li id="tb_5" class="normaltab" onclick="i:HoverLi(5);"> 第五页</li>
    </ul>
  </div>
 <form action="test.action" id="form1"  name="form1" method="post">
<div class="ctt" id="tbc_01">
  <table width="70%" height="100" border="0">
    <tr>
      <td height="57"><input type="text" name="user1.t1" value=""></td>
    </tr>
  </table>
</div>
</form>
<!--------------------------------------------------------1 end---------------------------------------------->
 <form action="test.action" id="form2"  name="form2" method="post">
<div class="undis" id="tbc_02">
  <table width="70%" height="100" border="0">
    <tr>
      <td height="57"><input type="text" name="user2.t2" value=""></td>
    </tr>
  </table>
</div>
</form>
<!--------------------------------------------------------2 end---------------------------------------------->
 <form action="test.action" id="form3"  name="form3" method="post">
<div class="undis" id="tbc_03">
  <table width="70%" height="140" border="0">
    <tr>
      <td height="57"><input type="text" name="user3.t3" value=""></td>
    </tr>
  </table>
</div>
</form>
<!--------------------------------------------------------3 end---------------------------------------------->
 <form action="test.action" id="form4" name="form4" method="post">
<div class="undis" id="tbc_04">
  <table width="70%" height="140" border="0">
    <tr>
      <td height="57"><input type="text" name="user4.t4" value=""></td>
    </tr>
  </table>
</div>
</form>
<!--------------------------------------------------------4 end---------------------------------------------->
 <form action="test.action" id="form5" name="form5" method="post">
<div class="undis" id="tbc_05">
  <table width="70%" height="140" border="0">
    <tr>
      <td height="57"><input type="text" name="user5.t5" value=""></td>
    </tr>
  </table>
</div>
</form>
<!--------------------------------------------------------5 end---------------------------------------------->
<div class="zhan"><button id="btnSubmit">提交</button></div><script type="text/javascript">$(function(){
 
    $("#btnSubmit").click(function(){              $("form[name='form1']").submit();              $("form[name='form2']").submit();
              $("form[name='form3']").submit();
              $("form[name='form4']").submit();
              $("form[name='form5']").submit();    })})/*
function check(){
//document.form.action="test.action";
//document.form.submit();
//document.forms[0].submit();
//document.forms[1].submit();
//document.forms[2].submit();
//document.forms[3].submit();
//document.forms[4].submit();
form1.target="form1";
from1.submit();
form2.target="form2";
from2.submit();
form3.target="form3";
from3.submit();
form4.target="form4";
from4.submit();
form5.target="form5";
from5.submit();
}
*/
</script>
</body>
路过的大哥帮小弟看看?

解决方案 »

  1.   

    建议你拼装form,即便是可以同步提交多个form,那也是低效的
      

  2.   

    form1.target="form1";
     from1.submit();
    这种写法没看过,马克下,看看后面高手怎么说
      

  3.   

    因为页面数据太多在一个form中的话影响效率且怕数据丢失,主要需求是实现页面数据的同步保存,保证数据的完整性。
      

  4.   

    主要需求是实现页面数据的同步保存,保证数据的完整性。就像上面的有五个页面每个页面都有几十个字段要保存,我希望同时提交到Action中进行保存,这几个页面时一份报告,分开保存如果有一个不成功的话会影响数据的完整性。
      

  5.   

    楼主的意思是每个表单在不同的页面?这个不是跟在线答题是一样的了。貌似不是这样的吧。
    楼主一个表单,用list去接受就对了,一起提交到后台
    struts中定义list<user> users 
      

  6.   

    这样做本来就不通的,当你执行了$("form[name='form1']").submit();
    页面已经跳转了,那么
                  $("form[name='form2']").submit();
                  $("form[name='form3']").submit();
                  $("form[name='form4']").submit();
                  $("form[name='form5']").submit();

    就根本不会执行到。你可以提交到iframe里面去
    <form action="test.action" id="form2"  name="form2" method="post" target="iframe1">
    <iframe name="iframe1" style="display: none;"></iframe>
    .....
    依此类推
      

  7.   

    思路太烂了,初学者吧?用ajax。
    要么每个form对应一个iframe,否则不可能实现
      

  8.   

    两种方法:
    1、客户端存储临时数据:只需要将每个表单用div分开,在每个表单提交事件中增加检察所有表单内容的方法,如果发现未填写则显示需要填写的表单,如果全部填写则将所有表单拼凑为1个表单并提交2、服务器端存储临时数据:将每个提交的表单数据封装后与这个用户绑定或存入session,在所有数据都填写完后一并提交数据库。
      

  9.   

    可以考虑使用ajax在onsubmit方法里写吧,提前先把2,3,4提交了或者完全抛弃表单,使用ajax
      

  10.   

    一个页面是不能同时提交多个form