Disable Radio Button Groups Onload | JavaScriptSource

Disable Radio Button Groups Onload

Greg Burghardt Aug 24, 2007

General

This unobtrusive script will disable groups of radio buttons on the page if one radio button is checked. It works with multiple groups and multiple forms on one page. Buttons are disabled on a group-by-group basis. Easy to use!


Are you a member?
Yes
No
I'm Not Sure

Will you attend the national event?
Yes
No

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: disableRadioButtons,js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


Leave a Response

(6 comments)

You would need to rewrite the script to do that.

Lee Oct 31, 2008

This is really cool... but I was wondering if something like this could be done 'onchange' instead of 'onload' with set(s) of radio buttons of my desire. (I think that's what the other 2 users (that commented here) wanted too.[br /][br /]For example, on your questions, if the first questions was:[br /]"Will you attend the national event?"[br /]If the 'No' radio button is selected then 2nd question: "Are you a member?" stays disabled, however if they answer 'Yes' then the 2nd radio set of questions become available.[br /][br /]Make sense?

Douglas Apr 27, 2008

As I mentioned to John above, it is for additional information when you don't want the user changing the original question.

Lee Oct 3, 2007

This is supposed to be used when additional information is required and you don't want the user changing the original question.

Lee Oct 3, 2007

I don't get it. The first group of radio buttons are always disabled. What use are they?

Brian Aug 27, 2007