I h...">

JQuery submit form using button

I have a form that contains the "POST" method and action = "abc.php" and the button type <input type ="button"> I have a handler, when I click this button, I want to send a request to abc.php, but nothing happens. No action is taken. I don’t want to change <input type ="button"> to <input type="submit> . How can I submit the form. Here is the code

 <form name= "form1" id ="form1" action ="abc.php" method="post"> <input type ="button" id="mybutton" value ="Add"> ...... //All form Elements. </form> $(document).ready(function() { //Load all elements }); $("#mybutton").click(function(e){ alert(true); //$("#frmpohdr").submit(); }); 

The above message gives an error, and I know that we need to enter the type of submit button for this method. How can I submit the form in abc.php when I click the button. I tried all the $ .ajax methods

+6
jquery
source share
3 answers

Have you tried using all the code inside?

In addition, if the form identifier is form 1, you should do this:

 $("#form1").submit(); 

And to avoid the default behavior, you should also add this link inside the click function:

 e.preventDefault(); 

I also recommend that you take a look at the jQuery Form plugin: http://jquery.malsup.com/form/

I hope I helped :)

+8
source share
 jq("#showDetail").click(function() { jq('#formName').submit(); }); <input type="button" id="showDetail" class="secondarybutton" value="Done" /> 
+3
source share

You either submit the form via an HTML form (i.e. change the input type = submit) Or you can use $. post / $. ajax

0
source share

All Articles