473,769 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

single checkbox enable/disable dropdown

I've been looking all over and I can't seem to find what ought to be
simple.

I need to disable a drop down when a checkbox is checked, and enable it
when same checkbox is unchecked.

I've found any number of scripts to disable / enable a drop down but they
are all made to work with 2 different buttons, radio group selections, etc.
I can't seem to come up with one that can toggle off a single checkbox.

help please.

Thanks
Nov 8 '06 #1
2 26371
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Untitl ed Document</title>
<script type="text/javascript">

window.onload = function() {
document.getEle mentById('demo' ).disabled =
document.getEle mentById('demo_ control1').chec ked;
}

</script>
</head>

<body>

<div id="container" >

<select name="demo" id="demo">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
<option value="Option 5">Option 5</option>
</select>

<label><input type="checkbox" name="demo_cont rol1" id="demo_contro l1"
onchange="docum ent.getElementB yId('demo').dis abled = this.checked;" />
Activate/Deactivate Selectbox</label>

</div>

</body>
</html>

Kevin wrote:
I've been looking all over and I can't seem to find what ought to be
simple.

I need to disable a drop down when a checkbox is checked, and enable it
when same checkbox is unchecked.

I've found any number of scripts to disable / enable a drop down but they
are all made to work with 2 different buttons, radio group selections, etc.
I can't seem to come up with one that can toggle off a single checkbox.

help please.

Thanks
Nov 8 '06 #2
i would make something more comprehensive to "normal" person :)

something like:

function foo(){
if (document.formn ame.checkboxnam e.checked) {
document.formna me.dropdownlist name.disabled=t rue;
}else{
document.formna me.dropdownlist name.disabled=f alse;
}

}

Here ur form tag
..
..
..
<input type="checkbox" name="checkboxn ame" value="somethin g"
onclick="foo()" >
..
..
..
Close form.
neogeek wrote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Untitl ed Document</title>
<script type="text/javascript">

window.onload = function() {
document.getEle mentById('demo' ).disabled =
document.getEle mentById('demo_ control1').chec ked;
}

</script>
</head>

<body>

<div id="container" >

<select name="demo" id="demo">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
<option value="Option 5">Option 5</option>
</select>

<label><input type="checkbox" name="demo_cont rol1" id="demo_contro l1"
onchange="docum ent.getElementB yId('demo').dis abled = this.checked;" />
Activate/Deactivate Selectbox</label>

</div>

</body>
</html>

Kevin wrote:
I've been looking all over and I can't seem to find what ought to be
simple.

I need to disable a drop down when a checkbox is checked, and enable it
when same checkbox is unchecked.

I've found any number of scripts to disable / enable a drop down but they
are all made to work with 2 different buttons, radio group selections, etc.
I can't seem to come up with one that can toggle off a single checkbox.

help please.

Thanks
Nov 8 '06 #3

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

Similar topics

2
9745
by: HolaGoogle | last post by:
Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field in my asp form i use a checkbox and fot he other field i use a normal text box. if the yes/no field is checked then the other field is enabled otherwise it has to be disabled.Here's what i've done so far: Do While Not ObjRS.EOF <td><input...
2
6472
by: HolaGoogle | last post by:
Can you please tell me the right way to do this?? it's realy important! thanks in advance... Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field in my asp form i use a checkbox and fot he other field i use a normal text box. if the yes/no field is checked then the other field is enabled...
3
9207
by: Bob Bedford | last post by:
I've this code: function checkdate(FormSubmit){ alert(document.getElementById('Mois').value); if(eval(document.getElementById('Mois'))>0 && eval(document.getElementById('Annee'))>0){ document.forms.getElementByID('SELECTCONSTRUCTOR').disabled = false; //can't reach the control here } else
3
15964
by: Alphonse Giambrone | last post by:
I am trying to enable/disable a requiredfieldvalidator on the client side and am generating an error. I had found some documentation on validation which states that I should be able to enable/disable validators on the client side. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp According to it and the little other info I was able to find, the way to accomplish what I want it to call...
1
4254
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 is selected - enable a field to use the M$ Datepicker. Using the code below works for most of our fields, however the problem is that when the field is re-enabled - it remembers the original date or data prior to it being disabled - despite the...
8
4285
by: John | last post by:
Hello. I have a search form for music albums which among other things I need to search all the song titles of the song. Normally in a search form I would have checkboxes the user can use to select whether or not to search a given field. In this case it is not practical to have 20 checkboxes (each album can have up to 20 song titles).
2
8916
by: RootSpy2006 | last post by:
Hi All, Problem Definition: --------------------- Microsoft Wirelss Keyboard works in BIOS but does not work when booting into windows. Discovered Work-around: ----------------------------- 1.> Open Device Manager(The keyboard device will have an exclamation and
2
4380
by: Naushad | last post by:
Hi all, I am using the countinous form. I want to Enable/Disable the some fields for perticular records as per the following condition when open the form. I have written this code in "On Current Event". I go on the perticular record its enable/dosable the following field for all records. I have tried this code in "On Open Even" but there is no effect. Please help me to solve this problem.
3
3197
by: sanndeb | last post by:
I want to enable/disable controls of a asp.net page against a logged in user's permission. say 'admin' & 'hr' can change user's birth date text-box in a page but others will see the text-box as disabled. so i wrote a function like this public enum UserRoles { GroupLead = 0x2, WebAdmin = 0x4, Developers = 0x8, Hr = 0x10,
0
9587
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9993
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.