note 85016 added to tutorial.forms
| From: | rosko at zeta dot org dot au | Date: | Mon, 11 Aug 2008 00:55:39 +0000 |
| Subject: | note 85016 added to tutorial.forms | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143353@lists.php.net to get a copy of this message | ||
@Lord Pacal: the attributes 'name' and 'id' have different intent and are used
differently. 'id' uniquely identifies an element in the HTML DOM, whereas 'name'
identifies the field that will be transmitted on the form submit. You can omit the 'id'
attribute, but not the 'name' attribute.
Where a field requires multiple elements, e.g. radio buttons and check boxes, the 'name'
attribute must be the same but the 'id' must be unique for each element.
'id' is useful for linking explicitly to the element, as in the following cases:
* CSS selector by ID
* JavaScript code, e.g. in-browser form validation or active forms
* the target of a <label> element
The last example is one not used nearly enough, as it allows the user to click on the text next to a
radio button or check box - a bigger target and thus easier for users not used to using a mouse:
<input type="checkbox" name="example" value="yes"
id="example_yes"/>
<label for="example_yes">Yes, I can click on the text and check the
box</label>
----
Server IP: 203.88.112.190
Probable Submitter: 210.1.199.245
----
Manual Page -- http://www.php.net/manual/en/tutorial.forms.php
Edit -- https://master.php.net/note/edit/85016
Del: integrated -- https://master.php.net/note/delete/85016/integrated
Del: useless -- https://master.php.net/note/delete/85016/useless
Del: bad code -- https://master.php.net/note/delete/85016/bad+code
Del: spam -- https://master.php.net/note/delete/85016/spam
Del: non-english -- https://master.php.net/note/delete/85016/non-english
Del: in docs -- https://master.php.net/note/delete/85016/in+docs
Del: other reasons-- https://master.php.net/note/delete/85016
Reject -- https://master.php.net/note/reject/85016
Search -- https://master.php.net/manage/user-notes.php