Sarra Sarra - 7 days ago 5
jQuery Question

Auto submit form in Razor

I want to submit automatically after click on label , I used Jquery but it did'nt work.

this is my Jquery Code :

<script type="text/javascript">

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




When T tested using alert function it works fine :

<script type="text/javascript">

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




tt is the id of label that I clicked on
This is razor code :

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

}


help ,

Answer

The problem was that I am using a input named "submit" in the form When I changed the name "submit" jquey code Works fine.