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 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染