Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

JavaScript Checkbox control HIDE or SHOW Drop-Down List, list of Checkbox controls list of DDL

views
     
exentric_nova
post Apr 15 2010, 10:15 PM

I Am Serious
******
Senior Member
1,702 posts

Joined: Jan 2003
From: Semenyih


I have done this before and it really was quite easy. Yes, you will be needing the ID of the drop down list.

My method is inserting that ID within the checkbox value. Once the checkbox is checked/unchecked, my script will capture the value of said checkbox, and toggle view according to the ID captured.

Different checkbox will have different value hence toggling different drop down list.

I can give an example of code, but are you using any framework or just plain Javascript? Since I'm only capable of doing JS using JQuery sweat.gif
exentric_nova
post Apr 15 2010, 10:44 PM

I Am Serious
******
Senior Member
1,702 posts

Joined: Jan 2003
From: Semenyih


Well if you don't mind JQuery, here it is. sweat.gif

CODE

$('input:checkbox').click(function() {
 var target = $(this).val();
 if(this.checked == true) {
  $('#'+target).show();
 }
 if(this.checked == false) {
  $('#'+target).hide();
 }
});


This post has been edited by exentric_nova: Apr 15 2010, 10:46 PM

 

Change to:
| Lo-Fi Version
0.1113sec    0.43    6 queries    GZIP Disabled
Time is now: 27th November 2025 - 10:46 PM