The difference between button and input submit

Source: Internet
Author: User

In IE, the button tag behaves almost the same as the input button, and does nothing if it is not assigned a script.
In non-IE, the button and input submit have similar behavior, the form will be submitted.
If you specify Type=submit for a button in IE, its performance will be similar to input submit.

However, when the button has the commit behavior (including what is not specified in the non-IE and the type=submit is specified in IE), it has a very interesting distinction with input submit: There are two such buttons in a form, Only the value of the clicked button is committed at commit, not the value of the button that is not clicked. If there are two input submissions in a form, the value of two input submit will be submitted regardless of which one is clicked!

With this distinction, different responses can be generated on the server side for clicking on different buttons. Take different names for multiple buttons, write different program segments for different situations, detect which value is being committed, and then decide which program segment to call.

When the value of the button is submitted, the performance of the two classes of browsers is also different, ie always submits the text between <button> and </button> as value, regardless of the value specified by the button's Value property. Non-IE always submits the value of the Value property, and if this value is not specified, an empty string is submitted, ignoring the text of the label between tabs. To use uniform logic to determine which button is clicked, it is only possible to determine if the button's corresponding get or post array member exists (defined).

The difference between button and input submit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.