douyi4991 2013-10-09 16:12
浏览 24

在另一个表格中提交表格

I have a form with POST method and an action of another page.

Within the form i have another form that I need to make submit with a different action but its submitting with the main form action.

this is my second form:

<script>
    function formSubmit()
    {
        document.getElementById("invoices_form").submit();
    }
</script>

<form action="resend_multiple_invoices.php" name="invoices_form" method="post">
    <input type="button" onclick="formSubmit()" value="Send Invoices" />
</form>

how can i get it to submit the second form and not the main one?

  • 写回答

2条回答 默认 最新

  • douxiajia6720 2013-10-09 16:41
    关注

    You cannot (universally) submit a nested form separately from its parent form. Nested forms are invalid HTML as outlined in the W3C prohibitions.

    To solve your problem, I suggest you use two separate forms as follows:

    <script>
        function invoicesFormSubmit()
        {
           document.getElementById("invoices_form").submit();
        }
    
        function otherFormSubmit()
        {
           document.getElementById("other_form").submit();
        }
    </script>
    
    <form action="resend_multiple_invoices.php" name="invoices_form" method="post">
    
        //
        // Input fields go here
        //
    
        <input type="button" onclick="invoicesFormSubmit()" value="Send Invoices" />
    </form>
    
    <form action="other_method.php" name="other_form" method="post">
    
        //
        // Input fields go here
        //
    
        <input type="button" onclick="otherFormSubmit()" value="Other Method" />
    </form>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line