Dynamically enabling/disabling radio button

Discussion in 'Javascript' started by dougawells@gmail.com, Mar 30, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. 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.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
    Thomas 'PointedEars' Lahn, Mar 30, 2006
    #2
    1. Advertising

  3. Guest

    Thanks much - that did it. I think the issue was that I didn't realize
    that it was boolean.
    Doug
    , Mar 30, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CGuy
    Replies:
    2
    Views:
    1,998
  2. Replies:
    2
    Views:
    527
  3. Hiten
    Replies:
    1
    Views:
    609
    Vidar Petursson
    May 26, 2004
  4. John Hopper

    Disabling radio button client - side

    John Hopper, Feb 2, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    155
    Guess
    Feb 22, 2005
  5. ~Maheshkumar.R

    Enabling/ Disabling Radio button in client side = Asp.net

    ~Maheshkumar.R, Mar 22, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    191
    ~Maheshkumar.R
    Mar 22, 2005
Loading...

Share This Page