[thelist] Radio Button Value Property Does Not Exist in Netscape 6.1?

gregory.john.toland at census.gov gregory.john.toland at census.gov
Tue Oct 30 07:21:22 CST 2001


Thanks to James and Jeff.  You were both right.  I changed the id's to
unique values (Ex. id="txtStep1_t, txtStep1_n) and it works!  I had a
feeling the braces, [], were not the correct solution even though it may
have worked.  Thanks again!

Greg

> "change id="txtStep1" to id="txtStep1[]" and it works in NS4,6,IE5 ...

    Hmm. That doesn't seem right to me. Instead, I would say that your
problem is in the duplication of the id for both radio inputs. In IE, by
using an id for more than one element, you implicitly create an array of
elements for that id. However, the HTML 4.01 recommendation declares that
an
id "must be unique in a document." [1] (Oh, and the braces are not legal
characters for an id value [2].) The workaround that you've been given
would
seem to suggest that Netscape 6 does something similar to IE by creating an
array, but it could also be considered buggy behavior that may well be
altered in a future Mozilla release. I would not rely on it.
    Remember: you can (in fact, for a radio element, must) duplicate the
value of the name attribute within a form; but you should *not* duplicate
the id value.

James Aylard

1. http://www.w3.org/TR/html401/struct/global.html#adef-id
2. http://www.w3.org/TR/html401/types.html#type-id

---------------------------------------------------------------------------

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: gregory.john.toland at census.gov
>
> Problem solved!  I received this from a gentlemen on
> a Javascript email list.
>
> "change id="txtStep1" to id="txtStep1[]" and it works
> in NS4,6,IE5 ...
>
> ...because "txtStep1" is the name of an array, and NS6
> is just more strict about it being properly identified
> as one ..."
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

that doesn't feel right to me at all.  i'd say more testing is in order.
how does nn6.1 behave when you remove the id attributes from the <input>s?

if it works, then there's a bug in nn6.1 in what it does when it encounters
items with the same id.  fwiw, the default behavior is to turn the id'ed
elements by the same id into an array of id'ed elements like same named
forms, same named form elements, same named images, etc.

when i use id attributes on radio buttons it's to give a handle for the
label tag.  in that case i combine name and value attributes to create a
unique id.  otherwise the label won't work properly.

<input
 type="radio"
 name="gender"
 id="gender_m"
 value="m"
> <label for="gender_m"
>Male</label>

<input
 type="radio"
 name="gender"
 id="gender_f"
 value="f"
> <label for="gender_f"
>Female</label>

using non-alphanumeric characters in the value of the id attribute just
feels dirty to me.


thanks,

.jeff






More information about the thelist mailing list