Robi wrote:
hygum wrote in message news:11*********************@g14g2000cwa.googlegro ups.com...
I have give it a try, but it doesn't work for me, whats wrong:
http://sneleopard.dk/radio.htm
I know this is the Javascript NG, but why don't you use the <label> tag instead?
Because it is unsuitable - see below (thought the OP's requirements are
pretty vague).
<form name=demoform>
<label>
<input type=radio name=agreebox1>Clicking this text also checks the radio to the left.
</label><br>
<label>
<input type=radio name=agreebox2>Clicking this text also checks the radio to the left.
</label>
</form>
The HTML spec says that in the absence of a 'for' attribute, the label
applies to the enclosed element - however IE doesn't follow the spec.
You must use the 'for' attribute and an id on the radio button.
The HTML spec is also ambiguous about how to deal with sets of radio
buttons (in this case, two sets of one button) where none are checked by
default:
<URL:http://www.w3.org/TR/html4/interact/forms.html#radio>
Browsers can make their own decision regarding which one is checked by
default - most seem to not check any. The issue then becomes how to
return the form to the original state - once one button is checked,
users can't get back to none checked without either resetting the form
or reloading the page.
It is also a good idea to always enclose attribute values in quotes,
even though they are not always needed.
<form name="demoform" action="">
<label for="agreebox1">
<input type="radio" name="agreebox" id="agreebox1">Clicking
this text also checks the radio to the left.
</label><br>
<label for="agreebox2">
<input type="radio" name="agreebox" id="agreebox2">Clicking
this text also checks the radio to the left.
</label><br>
<input type="reset">
</form>
However, the OP probably wants to make the radio checked based on the
change of another element, in which case a label is not suitable as
putting a second element inside the label creates serious usability issues:
- in Firefox the label keeps putting focus on the radio button
whenever the other elements get focus from clicks but not from keyboard
navigation.
- in IE, the other element is ignored so that clicks on it do not
check the radio button.
--
Rob