如何在chrome中提交javascript表单

如何在chrome中提交javascript表单,javascript,jquery,asp.net-mvc-3,Javascript,Jquery,Asp.net Mvc 3,嗨,我在JavaScript、jQuery和MVC应用程序中工作 document.forms['shipform'].submit(); 在这里,我像这样提交我的表格。 我在这一页总共有三张表格。 这是我的表格: <% using (Html.BeginForm("OrderShipments", "Shipments", FormMethod.Post, new { @id = "shipform" })) // Creates <form> {%> <

嗨,我在JavaScript、jQuery和MVC应用程序中工作

document.forms['shipform'].submit();
在这里,我像这样提交我的表格。 我在这一页总共有三张表格。 这是我的表格:

<% using (Html.BeginForm("OrderShipments", "Shipments", FormMethod.Post, new { @id = "shipform" })) // Creates <form>
{%>
    <input type="hidden" id="Hiddenid" name="orderId" />
    <input type="submit" value="book" style="display: none" />
<%} %>

如果我使用表单[0],如果我在一页中有三个表单,会采用哪种表单?

如果您使用jQuery,您可以这样做:

$('#shipform').submit();
假设代码输出一个ID=shipform的表单


您拥有的代码将根据表单名称提交表单:

 document.forms['shipform'].submit();
                ^^^ form name not ID
如果您想通过表单ID提交表单,请使用:

 document.getElementById('shipform').submit();
或jQuery:

$('#shipform').submit();
您可以使用getElementById获取表单,然后提交:

这应该是你的表格。 假设{@id=shipform}将表单上的id设置为shipform


如果您使用表单[0],它应该使用页面上的第一个表单,因此在html中首先加载的表单。

开发者控制台中显示的错误是什么?请您更准确地说明哪些不起作用?它不提交、提交全部或提交一个?
 document.getElementById('shipform').submit();
$('#shipform').submit();
document.getElementById("shipform").submit();