468,104 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,104 developers. It's quick & easy.

Dynamically enabling/disabling radio button

Hi-
I'm wanting to have a set of radio buttons disabled when a form is
displayed, then if they check another specific radio button, those
would become enabled. I've tried setting it via
window.document.formname.radiogroup.disabled="true "; (or false) - but
that doesn't seem to work. I've seen this done with text boxes, but not
with radio buttons. Can anyone give any help?

Thanks

Mar 30 '06 #1
2 5994
do********@gmail.com wrote:
I'm wanting to have a set of radio buttons disabled when a form is
displayed, then if they check another specific radio button, those
would become enabled. I've tried setting it via
window.document.formname.radiogroup.disabled="true "; (or false) - but
that doesn't seem to work.


Elements with the same name, especially all radio buttons of a button
group, create a HTMLCollection object in the DOM. The property value
is of type `boolean', not of type `string'.

<URL:http://www.w3.org/DOM-Level-2-HTML/html.html#ID-50886781>

It should be something like this:

var rbs = window.document.forms['formname'].elements['radiogroup'];
for (var i = rbs.length; i--;)
{
rbs[i].disabled = true; // or false
}

Consider disabling a `fieldset' element that contains the radio button
group, instead (untested), and be sure to do feature tests on runtime.

<URL:http://jibbering.com/faq/#FAQ4_13>
<URL:http://pointedears.de/scripts/test/whatami>
PointedEars
Mar 30 '06 #2
Thanks much - that did it. I think the issue was that I didn't realize
that it was boolean.
Doug

Mar 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by TheKeith | last post: by
6 posts views Thread by Leonard | last post: by
2 posts views Thread by adeelanjum2001 | last post: by
7 posts views Thread by John Meyer | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.