From: Michael Winter on
On 09/01/2006 21:13, Thomas 'PointedEars' Lahn wrote:

> Michael Winter wrote:

[snip]

>> The name attributes that are, on the whole, backwards-compatible
>> identifiers (A, APPLET, FORM, FRAME, IFRAME, IMG, MAP) should be unique.
>
> How did you get that idea?

I recall a similar discussion last year.

Subject: firefox and innerHTML
Message-ID: <ewSAe.68269$G8.41590(a)text.news.blueyonder.co.uk>
Date: 2005-07-12 16:49:14 GMT

Though browsers can cope with duplicated attribute values, it is my
opinion that the /intent/ was for them to be unique.

As I mention in the cited post, the addition of these name attribute was
a revision to HTML 4.0 (which introduced the id attribute). Netscape,
which first designed and implemented several of the listed elements
before HTML 4.0, and did not support the id attribute, presumably
adopted the name attribute as an identifier due to the precedent set by
links (that is, A elements).

As I also note in that post, the collection nature of DOM 0 does not
extend to FORM elements. In a quick test in Fx 1.5 (because it was
running), it doesn't cover APPLET, A (obviously), IMG, or IFRAME
elements, either (I didn't test FRAME and MAP elements). If duplication
was expected, why would scripting mechanisms not have been written to cope?

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
From: VK on

Lee wrote:
> Where did you get the idea that names must be unique?
> Have you never used checkboxes?

You meant to say "radio button" of course. Yes, radio button *group* is
one, and what's going to be two?
It is nice from W3C to provide a whole separate method for a single
case instance, but should it be added then to form or radio object
itself instead?

The only other occasion I may think of (with my humble mind of course)
is that ugly "improvement" of PHP where elements named like "name[]"
will be automatically glued together into array on the server side. I
call this ugly because one should never break long time commonly
accepted standards to implement your own freshly invented ones.
Plus it gives a terrible school to newcomers. If you look at this group
archives like 2-3 years ago it will be full of questions like: how to
access form element named "foo[]" - document.forms[0].foo[] doesn't
work! and similar... Plus a reasonnable question after such "practice"
is: why the hell id's should be any different? - thanks to PHP.
Thinking back document.getElementsByName may be a W3C "endorsment"
towards PHP (? pure speculation).

From: Matt Kruse on
VK wrote:
> You meant to say "radio button" of course. Yes, radio button *group*
> is one, and what's going to be two?
> It is nice from W3C to provide a whole separate method for a single
> case instance, but should it be added then to form or radio object
> itself instead?

I often use forms with multiple <input> tags with the same name.
Radio buttons are not a special case, it's just a common example of the
general case.
Multiple inputs with the same name (even of different types!) has been
supported forever.

> The only other occasion I may think of (with my humble mind of course)
> is that ugly "improvement" of PHP where elements named like "name[]"
> will be automatically glued together into array on the server side. I
> call this ugly because one should never break long time commonly
> accepted standards to implement your own freshly invented ones.

Which standard is broken? None.

> Plus it gives a terrible school to newcomers. If you look at this
> group archives like 2-3 years ago it will be full of questions like:
> how to access form element named "foo[]" - document.forms[0].foo[]
> doesn't work! and similar...

Which is why I always recommend accessing form elements with the syntax:

document.forms['formname'].elements['elementname']

This will cause no problems with form fields with '[]' in them.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


From: Randy Webb on
VK said the following on 1/9/2006 5:32 PM:

<snip>

> I call this ugly because one should never break long time commonly
> accepted standards to implement your own freshly invented ones.

There are terms for breaking long time standards to implement your own:

progress
innovation

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
From: Matt Silberstein on
On Mon, 09 Jan 2006 17:22:52 +0100, in comp.lang.javascript , Thomas
'PointedEars' Lahn <PointedEars(a)web.de> in
<2057466.jZvhszIjaO(a)PointedEars.de> wrote:

>Frances wrote:
>
[snip]

>> if I search in google for document.getElementsByName with or w/o that
>> "s" I find entries for both.
>
>Yes, there are many incompetent people out there which is why the number
>of Google hits does not qualify as proof for existence of a name.

Which makes me wonder what is the verifiably objectively wrong
statement with the largest number of Google hits?


--
Matt Silberstein

Do something today about the Darfur Genocide

http://www.beawitness.org
http://www.darfurgenocide.org
http://www.savedarfur.org

"Darfur: A Genocide We can Stop"
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: How to rotate the image
Next: javascript:false