Ed Jay wrote:
I use window.document.form1.myCheckbox.checked=false;
to uncheck (reset) several checkboxes. What is an equivalent for resetting
a set of interrelated radio boxes?
Not quite sure what you mean by 'a set of interrelated radio boxes'.
I'll guess that you mean a set of radio buttons that all share the same
name ('myCheckbox' in your example) and that 'resetting' means return
them to their default state when the page loaded.
The trivial answer is if they are in a form, reset the form. If they
aren't, or you want to reset just the set of buttons, loop through them
and set their checked property to their 'defaultChecked' property:
var cBoxes = document.form1.myCheckbox;
for(var i=0, n=cBoxes.length; i<n; ++i){
cBoxes[i].checked = cBoxes[i].defaultChecked;
}
As a matter of interest, opinion is divided on whether one radio button
should always be checked - the relevant part of the HTML spec says that:
"...authors should ensure that in each set of radio buttons that
one is initially 'on'."
<URL:
http://www.w3.org/TR/html4/interact/forms.html#radio >
--
Rob