duanjia9577 2014-07-30 14:37
浏览 38
已采纳

使用一个也传递帖子数据的提交按钮提交多个表单

I'm building a tool that has multiple forms. One form per tab, that also allows you to create new tabs, and thus new forms.

The way I built each tab is like this

    <div class="tabs_item">
        <h4>Tab01</h4>
        <?php $globalIncrement++; include 'qBox.php';  ?>
    </div> 

qBox.php is a form all on it's own, with ids and classes that increment based on $globalIncrement. (the reason I do this is somewhat unrelated).

When the user hits the "submit" button, the form takes all the POST data, and with that we create the results.php page.

Problem is, when you submit, it only takes the POST data from the active tab, and not the POST data from the other tabs (which, again, contain different forms).

I tried to rectify this problem with the following code:

$('#subBtn').click(function(){
$('form').each(function(){
    $(this).submit();
});
});

However, this only partially works. The form action is still performed, thus bringing me to results.php. However, now, none of the POST data is being retrieved.

How can I submit all these forms, while also passing through the POST data to the next page?

Thank you in advance!

EDIT:

Solved it myself. Rather than having a form on every tab, I simply wrapped every tab item inside of an all-encompassing form. Works great.

Thank you to all that answered.

  • 写回答

5条回答 默认 最新

  • doulao2029 2014-07-30 15:13
    关注

    Solved it myself. Rather than having a form on every tab, I simply wrapped every tab item inside of an all-encompassing form. Works great.

    Thank you to all that answered.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多