Foofy (formerly known as Spaghetti) wrote:
> Something I've always wondered is why it uses the ID attribute, especially
> since that must be unique throughout the document? What about a page with
> multiple forms that are similar? What's the reason behind this? I'm just
> curious...
I'm not sure what you don't get.
In the case of radio buttons, each one needs the same name -- it's how
they're grouped.
IDs are always unique and they need to be for the purpose of linking to
fragment identifiers, document.getElementById, etc.
So, if one is assigning IDs to a group of radio buttons then they must all
be different.
A technique I often use is to give radio buttons an ID of name_value. That
is:
<input type="radio" name="food" value="beef" id="food_beef">
<label for="food_beef">I want the beef meal</label>
<input type="radio" name="food" value="fish" id="food_fish">
<label for="food_fish">I want the fish meal</label>
<input type="radio" name="food" value="veg" id="food_veg">
<label for="food_veg">I want the vegitarian meal</label>
--
Toby A Inkster BSc (Hons) ARCS
Contact Me -
http://www.goddamn.co.uk/tobyink/?page=132