Definition and Usage The name attribute is used to identify form data after it has been submitted. Several button elements may share the sa...
Definition and Usage
The name attribute is used to identify form data after it has been submitted.Several button elements may share the same name attribute (unlike the unique id attribute). This allows you to have more than one button with the same name, that can submit different values when used in a form.
Important: Be careful when using the button element in a form. In a form the different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will send the content of the value attribute. When in a form, use the input element instead.
Syntax
<button name="name"> |
Syntax Example
<button name="option1"> |
Attribute Values
Value | Description |
---|---|
name | Specifies the name of the button. |
Browser Support
The attribute is supported in all major browsers.Note: When used in a form, Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will send the content of the value attribute.
Example
<form name="select" action="demo_button_name.asp" method="get"> Select one: <br/> <button name="option" value="html" type="submit">HTML</button> <br /> <button name="option" value="xhtml" type="submit">XHTML</button> </form> |
Note: In the example above we have added the type attribute. This is to ensure that all browsers will treat this as a submit button. See the type attribute for an explanation.