David David - 2 years ago 80
PHP Question

Input name submit not submit the form

If I name button to "submit" the form is not submitting. But If I changed the name something else the form is submitting.


<form name="my_form" action="/search" method="get" id="my_form">
/** code **/
<button name="submit" type="submit"><i class="fa fa-angle-right"></i></button>

Here If I change
name somthing else then it will work and submit the form.


$( document ).ready(function() {
$('.attr_list').on('ifChanged', function(event){
alert("message will display"); // here alert will come but form is not submitting

Why it is not submitting if I named the button to "submit" ?

Answer Source

I think you should change your button name from "submit" to anything else.


Form elements have a property called submit which is the function you can call to submit them. (jQuery uses this under the covers when you call submit on the jQuery instance.) But Form elements also receive properties for each of the fields in the form, using the field's name, and so if you have a field called "submit", it overrides the submit function, which means you can't submit the form programmatically.

Your code should be:

<form name="my_form" action="/search" method="get" id="my_form">
/** code **/
<button name="othername" type="submit"><i class="fa fa-angle-right"></i></button>

It will work....

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download