Dynamically enabling/disabling radio button

D

dougawells

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
 
T

Thomas 'PointedEars' Lahn

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.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
 
D

dougawells

Thanks much - that did it. I think the issue was that I didn't realize
that it was boolean.
Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top