2016-05-17 50 views
-1

我想在点击标签后自动提交,我用Jquery,但它没有工作。在Razor自动提交表格

这是我的jQuery代码:

<script type="text/javascript"> 

$("#tt").click(function() { 
    $("#demo-form2").submit(); 
}); 

当T使用提醒功能,它工作正常测试:

<script type="text/javascript"> 

$("#tt").click(function() { 
    alert("Bye! You now leave p1!"); 
}); 

TT是标签的ID我点击 这是剃须刀代码:

@using (Html.BeginForm("Index2", "Commande", FormMethod.Post, new { @class = "form-horizontal form-label-left", role = "form", @id = "demo-form2" })) 
      { 
       @Html.ValidationSummary(true) 
         <table> 
         <tr> 

          <th id="tt"> 
           Code Article 
          </th> 
         </tr>... 

} 

帮助,

+3

一些html请吗? – Satpal

+1

是你的表单的正确ID吗?你能分享其余的代码吗?如果这是你的页面中唯一的表单,你可以试试$('form')。submit(); – Nikitesh

+1

正确检查表单ID! – Poria

回答

0

问题是,我使用了一个名为形式“提交”的输入。

当我更改名称“提交”jQuery代码工作正常。