name (HTML attribute)
Example
Thename
attribute provides a way of referencing the input data:
<form> <label for="pin">Your 4-digit PIN:</label> <input type="password" name="pin" id="pin" maxlength="4" size="6" /> … </form>
Description
The name attribute is
used for referencing form data after it is submitted
(it can also be referenced by JavaScript client-side using this
attribute). Unlike the id attribute - which must
have a unique value when applied to each form control - the
name attribute may be applied to numerous form
controls with the same value (although in practice this only
happens with radio input buttons). Note that only
form elements that have a name
attribute will have their values passed through to the page/script
specified in the form’s action
attribute.
Value
Any name that the developer chooses (not containing spaces or special characters).
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Causes no compatibility issues. It has excellent support across all tested browsers.
User-contributed notes
- ID:
- #1
- Date:
- Fri, 28 Mar 2008 11:17:05 GMT
It's not true that using the same name for multiple form controls only happens with radio buttons. It's quite a common approach when you have a large number of checkboxes, too, although not all server-side technologies support it. (Perhaps not all browsers, either, for that matter.)
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

