Form Submit button input and button, a difference

Source: Internet
Author: User

Now popular in the Web page, form submit data buttons most common practical three kinds, one is input, one is button, the last, is other such as a tag, div tag, span tag instead of. In previous days, everyone was accustomed to using input because he had type=submit directly, and the button did not, it is more suitable for the expression button.
However...

First we say: the input tag; this is the most common, not much said: when type= "submit", submit form data!

Button tag: tested: In <IE8 Browser, the button's default type= "button", so we want to make it possible to submit the form data submitted need to set type= "submit", and from IE8 to the default is Type= " Submit ", but also is Microsoft step-by-step forward it.

You can test it yourself:

First create a PHP file demo.php to receive the form data:

<?phpvar_dump ($_post);? >

Then create an HTML file, demo.html, to display the form:

<form method= "POST" action= "demo.php" ><input type= "Submit" Name= "foo" value= "commit" ><input type= "Submit" Name= "Bar" value= "save" ></form><form method= "post" action= "demo.php" ><button type= "Submit" Name= " Foo "value=" Foo_value "> Submit </button><button type=" Submit "Name=" Bar "value=" Bar_value "> Save </button ></form>

Using Firefox, you can see the difference between input and button: the Input submit button displays the text that is value, and the button commits the text and value are independent, in this sense, the button is more expressive, is a more recommended way to implement a Submit button.

There are also effects on how they are displayed in different browsers, which will also affect our choices (we'll look at other labels to better maintain the uniformity of the presentation): This is mainly FF and opera under Line-height to input[' button '],button does not work .

Summary: In theory, the button form of the submit buttons is better than the input form of the submit button. However, if you consider browser versatility, it is often only possible to use the Submit button in input form.

Again: a label (reproduced below:)

Read some of the previous articles, said to use a tag instead of the submit button better, because the Submit button under the IE6 there will be some compatibility issues, bad unity, and input line height in the browser is uneven, not with line-height control, When the button has some interaction effect, a tag is easier to implement, hover effect, so many front-end like to use a tag instead of input.

But it involves a point, input submit can be used to submit the value of the form, and a tag does not seem good value, so a lot of programs require the front-end developers to change the a tag to input, and then after the search, found that a tag is the same can be submitted form, the following method is attached, Also hope that those who have been asked to change the page to change the front-end staff to tell the program a tag can submit the form. The way a label submits a form is actually very simple, first you write a method
function Tosubmit () {
var myform=document.getelementbyidx_x ("MyForm");
Myform.submit ();
 }
then submit the submission using this method
This allows the form to be submitted, which is not very simple. ----------------------------------------------------------------------------------------------------------reference:http://www.w3school.com.cn/tags/tag_button.asp style settings:CSS button style buttons tab and input Type=button the difference between the detailed

Form Submit button input and button, a difference

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.