473,503 Members | 11,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable radio buttons?

Within a single form I have a dropdown select box with 2 options and 2
radio buttons. If someone selects option 2 in the dropdown I would like to
make the radio buttons disabled, such that you cannot select either one of
them. If someone selects option 1 in the dropdown I would like the radio
buttons to be re-enabled. Is this, or something similar (checkboxes
instead of radio, etc) possible, and if so can someone point me to an
example? Thanks
Aug 2 '05 #1
2 1937
James Gardner <jg********@columbia.PLEASE.edu> wrote in message news:96*******************@216.196.97.136...
Within a single form I have a dropdown select box with 2 options and 2
radio buttons. If someone selects option 2 in the dropdown I would like to
make the radio buttons disabled, such that you cannot select either one of
them. If someone selects option 1 in the dropdown I would like the radio
buttons to be re-enabled.


You need a simple function to toggle all the buttons in a specifed set:

<SCRIPT type='text/javascript'>

function enableRB(bSet, flag)
{
for(var i=0; i<bSet.length; i++)
bSet[i].disabled=!flag;
}

</SCRIPT>

Then assuming that your set of radio buttons is *named* 'rbSet' ,

<SELECT onchange='enableRB( this.form.rbSet, this.selectedIndex==1?false:true )'>
--
Stephen Chalmers
547265617375726520627572696564206174204F2E532E2072 65663A205451323437393134

Aug 2 '05 #2
Stephen Chalmers wrote:
James Gardner <jg********@columbia.PLEASE.edu> wrote in message news:96*******************@216.196.97.136...
Within a single form I have a dropdown select box with 2 options and 2
radio buttons. If someone selects option 2 in the dropdown I would like to
make the radio buttons disabled, such that you cannot select either one of
them. If someone selects option 1 in the dropdown I would like the radio
buttons to be re-enabled.

You need a simple function to toggle all the buttons in a specifed set:

<SCRIPT type='text/javascript'>


The example can be simplified a little if both the following changes are
made:

function enableRB(bSet, flag)
{
for(var i=0; i<bSet.length; i++)
bSet[i].disabled=!flag;
bSet[i].disabled = flag;
}

</SCRIPT>

Then assuming that your set of radio buttons is *named* 'rbSet' ,

<SELECT onchange='enableRB( this.form.rbSet, this.selectedIndex==1?false:true )'>


<SELECT onchange='enbleRB( this.form.rbSet, (this.selectedIndex==1) )'>

[...]

--
Rob
Aug 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
16500
by: J Belly | last post by:
Hi, I have a table of questions (with radio buttons) that I want to appear greyed out so that users can feel they can skip it and go on to the next page. But if they should choose to answer the...
1
4223
by: hortoristic | last post by:
We are using JavaScript to Enable/Disable certain fields on web pages based on business rules. A simple example is if when using an option type tag, and the two options are Yes and No. If YES...
2
6535
by: headware | last post by:
How can I disable a single radio button in a RadioButtonList? I tried doing this: radioList.Items.Attributes.Add("disabled", "true"); radioList.Items.Attributes.Add("disabled", "true"); but it...
1
5052
by: | last post by:
Is it possible to disable just a certain radio button in a RadioButtonList control? I've researched this issue for a while now and haven't come up with anything. Thanks, Dave
4
2943
by: enahar | last post by:
I have created RadioButtonList1 having 2 radio buttons in the list.How to make enable/disable only 1 radio button in the RadioButtonlist. Thanks for your help. Regards.
6
8574
by: millw0rm | last post by:
i got a form full of radio buttons appx. 60-70, depends on the page. Some times 60, sometimes 55.... After certain period of time, i want to disable or make readonly all the radio button inside the...
1
1895
by: scanreg | last post by:
My form needs to (1) direct to specified URLs based on a combination of form selections and (2) enable/disable form features based on selections within the form FORM Radio 1 - A - B - C ...
3
2428
by: sumanbangladesh | last post by:
Hi I have a page with 3 radio butons. If I select a specific one,then I like to view some other radio buttons otherwise the other radio buttons will be remain disabled or invisible. I am very...
2
2385
by: nudrat | last post by:
Hi All, I have two groups of radion button sets. based on selection of one group made the other group radio buttons disable. suppose some one has selected one radion button from a group, so one...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.