Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > single checkbox enable/disable dropdown

Reply
Thread Tools

single checkbox enable/disable dropdown

 
 
Kevin
Guest
Posts: n/a
 
      11-08-2006
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
 
Reply With Quote
 
 
 
 
neogeek
Guest
Posts: n/a
 
      11-08-2006
<!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>Untitled Document</title>
<script type="text/javascript">

window.onload = function() {
document.getElementById('demo').disabled =
document.getElementById('demo_control1').checked;
}

</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_control1" id="demo_control1"
onchange="document.getElementById('demo').disabled = 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


 
Reply With Quote
 
 
 
 
Ruso
Guest
Posts: n/a
 
      11-08-2006
i would make something more comprehensive to "normal" person

something like:

function foo(){
if (document.formname.checkboxname.checked) {
document.formname.dropdownlistname.disabled=true;
}else{
document.formname.dropdownlistname.disabled=false;
}

}

Here ur form tag
..
..
..
<input type="checkbox" name="checkboxname" value="something"
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>Untitled Document</title>
> <script type="text/javascript">
>
> window.onload = function() {
> document.getElementById('demo').disabled =
> document.getElementById('demo_control1').checked;
> }
>
> </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_control1" id="demo_control1"
> onchange="document.getElementById('demo').disabled = 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
ajax cascading dropdown: second dropdown disabled acadam ASP .Net 0 12-27-2006 10:59 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM
Edit Mode - How do I populate dropdown in edittemplate from dropdown in another column? Steve Myers ASP .Net Datagrid Control 2 11-20-2003 01:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57