RE: Accessible forms in XHTML

>but there IS a reason for the difference in values for the id 
>and name attributes? Is there a reason why they can't be the same?

Yes.  I ran into this very problem last week.  Let's assume that you have
this:

<p>Are You Working?</p>

<label for="workingYes">Yes</label>
<input type="radio" id="workingYes" name="workingYes" value="y" />

<label for="workingNo">No</label>
<input type="radio" id="workingNo" name="workingNo" value="n" />

Now this makes perfect sense, unless you don't know that checkboxes are
referenced in Javascript, PHP, etc. by an array.  In the above example, it
is possible to select both the Yes and No checkboxes.  Which doesn't work,
because you want Yes to be unchecked if No is checked.

So the markup has to look like this:

<p>Are You Working?</p>

<label for="workingYes">Yes</label>
<input type="radio" id="workingYes" name="working" value="y" />

<label for="workingNo">No</label>
<input type="radio" id="workingNo" name="working" value="n" />

Try it out and see for yourself.  Once you actually try to use the form, it
makes much more sense.

Randal

Received on Wednesday, 17 July 2002 07:40:50 UTC