首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp同步交付一个页面中的多个form

2012-12-15 
jsp同步提交一个页面中的多个form?bodydiv idtb_ classtb_ no-printulli idtb_1 classh

jsp同步提交一个页面中的多个form?
<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>
路过的大哥帮小弟看看?
[最优解释]
这样做本来就不通的,当你执行了$("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>
.....
依此类推
[其他解释]
此路不通。。。


把你最原始所期望的需求描述下,大家再给你点建议。
[其他解释]
两种方法:
1、客户端存储临时数据:只需要将每个表单用div分开,在每个表单提交事件中增加检察所有表单内容的方法,如果发现未填写则显示需要填写的表单,如果全部填写则将所有表单拼凑为1个表单并提交

2、服务器端存储临时数据:将每个提交的表单数据封装后与这个用户绑定或存入session,在所有数据都填写完后一并提交数据库。
[其他解释]
可以考虑使用ajax

在onsubmit方法里写吧,提前先把2,3,4提交了

或者完全抛弃表单,使用ajax
[其他解释]
建议你拼装form,即便是可以同步提交多个form,那也是低效的
[其他解释]
你这个第一个提交了,页面已经离开了,后面的请求多半就执行不到了,估计是这个效果哈。
楼主的意思是所有表单都一起提交?何不就在一个表单里面呢,估计还有其他需求。
描述一下……
[其他解释]
楼主的意思是每个表单在不同的页面?这个不是跟在线答题是一样的了。貌似不是这样的吧。
楼主一个表单,用list去接受就对了,一起提交到后台
struts中定义list<user> users 
[其他解释]
思路太烂了,初学者吧?用ajax。
要么每个form对应一个iframe,否则不可能实现

[其他解释]

引用:
此路不通。。。


把你最原始所期望的需求描述下,大家再给你点建议。


把不的要求描述清楚一点。
[其他解释]
form1.target="form1";
 from1.submit();
这种写法没看过,马克下,看看后面高手怎么说
[其他解释]
一个页面是不能同时提交多个form
[其他解释]
因为页面数据太多在一个form中的话影响效率且怕数据丢失,主要需求是实现页面数据的同步保存,保证数据的完整性。
[其他解释]
引用:
form1.target="form1";
 from1.submit();
这种写法没看过,马克下,看看后面高手怎么说

看网上有这样写的,试试不行

[其他解释]
引用:
此路不通。。。


把你最原始所期望的需求描述下,大家再给你点建议。

主要需求是实现页面数据的同步保存,保证数据的完整性。就像上面的有五个页面每个页面都有几十个字段要保存,我希望同时提交到Action中进行保存,这几个页面时一份报告,分开保存如果有一个不成功的话会影响数据的完整性。
[其他解释]
引用:
思路太烂了,初学者吧?用ajax。
要么每个form对应一个iframe,否则不可能实现

字段狠多的,大概有1-200个
[其他解释]
引用:
这样做本来就不通的,当你执行了$("form[name='form1']").submit();
页面已经跳转了,那么
              $("form[name='form2']").submit();
              $("form[name='form3']").submit();
              $("form[name=……

后面的可以执行,我试过后台的打印信息执行了五次

热点排行