Re: [PHP] HTML id attribute and arrays
The "name" and "id" attributes do not have to be the same. Thank you, I thought it should be the same You're probably thinking of: http://www.w3.org/TR/html401/struct/links.html#h-12.2.3 "The id and name attributes share the same name space. This means that they cannot both define an anchor with the same name in the same document. It is permissible to use both attributes to specify an element's unique identifier for the following elements: A, APPLET, FORM, FRAME, IFRAME, IMG, and MAP. When both attributes are used on a single element, their values must be identical." Confusing, the "name" attribute on a form field ("input", "textarea", "select", etc) is different to the "name" attribute on a "a" or "form" element, so this rule does not apply to it. Thank you, Benjamin, for clarification. This sounds like the source of my (bogus) feeling. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML id attribute and arrays
On Sun, Dec 19, 2010 at 4:57 PM, Martin C wrote: >> The "name" and "id" attributes do not have to be the same. > > Thank you, I thought it should be the same (for same reason, maybe > compatibility between XHTML and HTML). But could not find anything on the > net which states this. So my memories might be corrupted :) You're probably thinking of: http://www.w3.org/TR/html401/struct/links.html#h-12.2.3 "The id and name attributes share the same name space. This means that they cannot both define an anchor with the same name in the same document. It is permissible to use both attributes to specify an element's unique identifier for the following elements: A, APPLET, FORM, FRAME, IFRAME, IMG, and MAP. When both attributes are used on a single element, their values must be identical." Confusing, the "name" attribute on a form field ("input", "textarea", "select", etc) is different to the "name" attribute on a "a" or "form" element, so this rule does not apply to it. -- Benjamin Hawkes-Lewis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML id attribute and arrays
How should I follow the HTML specification while having the passed parameters automatically converted to arrays in PHP? The "name" attribute, not the "id" attribute, is used as the key when submitting form values. The "name" and "id" attributes do not have to be the same. Thank you, I thought it should be the same (for same reason, maybe compatibility between XHTML and HTML). But could not find anything on the net which states this. So my memories might be corrupted :) Based on first tests, it works (but have not checked the W3C validator yet). Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML id attribute and arrays
How should I follow the HTML specification while having the passed parameters automatically converted to arrays in PHP? The "name" attribute, not the "id" attribute, is used as the key when submitting form values. The "name" and "id" attributes do not have to be the same. Thank you, I thought it should be the same (for same reason, maybe compatibility between XHTML and HTML). But could not find anything on the net which states this. So my memories might be corrupted :) Based on first tests, it works (but have not checked the W3C validator yet). Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML id attribute and arrays
What are you trying to accomplish? What do you think it wrong with the code below? On 12/17/2010 8:19 AM, Martin C wrote: Hi, PHP converts x[a]=b parameter of the HTTP request as an array named x with its item named a set to value b. So, it seems possible to have the following (X)HTML code: Unfortunatelly, HTML specification does not allow neither "[" nor "]" inside the id attribute. Specifically: * Must begin with a letter A-Z or a-z * Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".") * Values are case-sensitive How should I follow the HTML specification while having the passed parameters automatically converted to arrays in PHP? Thank you for any tips, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML id attribute and arrays
Martin C wrote: > How should I follow the HTML specification while having the passed > parameters automatically converted to arrays in PHP? The "name" attribute, not the "id" attribute, is used as the key when submitting form values. The "name" and "id" attributes do not have to be the same. -- Benjamin Hawkes-Lewis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php