在另一个表格内提交表格 - javascript

我有一个带有POST方法的表单以及另一个页面的操作。

在表单中,我还有另一种表单,我需要使用其他操作来进行提交,但是要通过主表单操作来进行提交。

这是我的第二种形式:

<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>

我怎样才能提交第二份表格而不是主要表格?

参考方案

您不能(普遍)与父表单分开提交嵌套表单。嵌套表单是W3C prohibitions中概述的无效HTML。

为了解决您的问题,建议您使用两种单独的形式,如下所示:

<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>

PHP Javascript更改浏览器后退按钮行为Laravel - javascript

我知道有各种各样的线程要求几乎相同的要求,但似乎没有一个真正满足我的需求。在我的网站上,我实现了搜索表单。一个简单的表单,其中包含一个名为searchQuery的输入字段和一个提交按钮。表单通过POST方法发送。我正在使用Laravel btw。。然后将搜索结果从控制器加载到视图中。这些在表中显示。现在来了有趣的部分:找到的元素是可单击的,并且您进入有关该元…

Javascript-从当前网址中删除查询字符串 - javascript

单击提交按钮后,我需要从网址中删除查询字符串值。我可以用jQuery做到这一点吗?当前网址:siteUrl/page.php?key=value 页面提交后:siteUrl/page.php 实际上,我已经从另一个带有查询字符串的页面着陆到当前页面。我需要在页面首次加载时查询字符串值以预填充一些详细信息。但是,一旦我提交了表格,我就需要删除查询字符串值。我已…

PHP json_encode数组到javascript关联数组 - javascript

我有一些从PHP中读取的mysqli列。它正在完美地获取和回显。$results = mysqli_fetch_assoc(mysqli_query($conn, $querystring)); echo json_encode($results); //$results = {"title":"Sea Shells"…

PHP-显示特殊字符 - javascript

允许用户输入的代码段//fetch user input and pass it in URL alertify.prompt("Please enter note/remarks for this Form (optional):", function (e,value) { if (e) { alertify.success(…

php curl远程页面javascript提取 - javascript

我有一个远程页面,下面显示了其源代码,<!DOCTYPE html> <html> <head> <title>somethingg blabla</title> </head> <body> <script type="text/javascript…