check box | data | Show today on CSDN see a question: http://community.csdn.net/Expert/topic/3496/3496350.xml?temp=.4479639.
At the request of the landlord, a close-up of the implementation code is as follows.
<!----------------------------------------------------------------------------------------------->
<HTML>
<HEAD>
<meta name= "Authour" content= "DANNY KANG" >
<meta name= "CreateDate" content= "2004-10-28" >
<meta name= "Keywords" content= "DANNY Kang,dannykang,dk,[d.k],pizz" >
<meta http-equiv=content-type content= "text/html; charset=gb2312 ">
<script language=javascript>
//'+--------------------------------------------
' + FileName:
' + created:2004-10-28. by Pizz [D.K]
' + modified:2004-10-28. by Pizz [D.K]
' + FUNCDESC: Using ASP and JavaScript to implement multiple check box Data Association display
//'+---------------------------------------------
The contents of the first check box
var dk_array1 = new Array ();
/* The following sections, you can use ASP dynamic generation * *
Dk_array1[dk_array1.length]=new Array (' 1 ', ' Category 1 '); Category ID, category name
Dk_array1[dk_array1.length]=new Array (' 2 ', ' Category 2 ');
Dk_array1[dk_array1.length]=new Array (' 3 ', ' Category 3 ');
Dk_array1[dk_array1.length]=new Array (' 4 ', ' Category 4 ');
Dk_array1[dk_array1.length]=new Array (' 5 ', ' Category 5 ');
Dk_array1[dk_array1.length]=new Array (' 6 ', ' Category 6 ');
Dk_array1[dk_array1.length]=new Array (' 7 ', ' Category 7 ');
Dk_array1[dk_array1.length]=new Array (' 8 ', ' Category 8 ');
///////////////////////////////////////////////////////
The contents of the Third check box
var dk_array3 = new Array ();
/* The following sections, you can use ASP dynamic generation * *
Dk_array3[dk_array3.length]=new Array (' 1 ', ' 1 ', ' small class 1.1 '); Category ID, small class ID, small class name
Dk_array3[dk_array3.length]=new Array (' 1 ', ' 2 ', ' small class 1.2 ');
Dk_array3[dk_array3.length]=new Array (' 1 ', ' 3 ', ' small class 1.3 ');
Dk_array3[dk_array3.length]=new Array (' 2 ', ' 4 ', ' small class 2.4 ');
Dk_array3[dk_array3.length]=new Array (' 2 ', ' 5 ', ' small class 2.5 ');
Dk_array3[dk_array3.length]=new Array (' 2 ', ' 6 ', ' small class 2.6 ');
Dk_array3[dk_array3.length]=new Array (' 2 ', ' 7 ', ' small class 2.7 ');
Dk_array3[dk_array3.length]=new Array (' 3 ', ' 8 ', ' small Class 3.8 ');
Dk_array3[dk_array3.length]=new Array (' 4 ', ' 9 ', ' small class 4.9 ');
Dk_array3[dk_array3.length]=new Array (' 4 ', ' 10 ', ' small Class 4.10 ');
Dk_array3[dk_array3.length]=new Array (' 4 ', ' 11 ', ' small class 4.11 ');
Dk_array3[dk_array3.length]=new Array (' 4 ', ' 12 ', ' small class 4.12 ');
Dk_array3[dk_array3.length]=new Array (' 5 ', ' 13 ', ' small Class 5.13 ');
Dk_array3[dk_array3.length]=new Array (' 5 ', ' 14 ', ' small Class 5.14 ');
Dk_array3[dk_array3.length]=new Array (' 6 ', ' 15 ', ' small class 6.15 ');
Dk_array3[dk_array3.length]=new Array (' 6 ', ' 16 ', ' small class 6.16 ');
Dk_array3[dk_array3.length]=new Array (' 6 ', ' 17 ', ' small Class 6.17 ');
Dk_array3[dk_array3.length]=new Array (' 6 ', ' 18 ', ' small Class 6.18 ');
Dk_array3[dk_array3.length]=new Array (' 6 ', ' 19 ', ' small class 6.19 ');
Dk_array3[dk_array3.length]=new Array (' 7 ', ' 20 ', ' small class 7.20 ');
Dk_array3[dk_array3.length]=new Array (' 8 ', ' 21 ', ' small Class 8.21 ');
Dk_array3[dk_array3.length]=new Array (' 8 ', ' 22 ', ' small Class 8.22 ');
///////////////////////////////////////////////////////
function Dk_addonto (obj,val,txt) {//Add one
if (dk_checkexists (obj,val,txt)) {
Alert (' option already exists: [' +obj.id+ '] ' + ' \ n Value: ' + val+ ' \ n-Text: ' +txt);
Return
}
var opt=new Option ();
Opt.value=val;
Opt.text=txt;
Obj.options.add (opt,0);
}
function Dk_initlistobject (Obj,array) {//initialization list
if (array.length) {
for (Var i=0;i<array.length;i++) {
Dk_addonto (obj,array[i][0],array[i][1]);
}
}
else {
Alert (' no data ');
}
}
function Dk_addto (src,obj) {//Add options to the specified list
for (Var i=0;i<src.length;i++) {
if (src.options[i].selected) {
Dk_addonto (Obj,src.options[i].value,src.options[i].text);
}
}
}
function Dk_selectall (obj) {//Select all options
for (Var i=0;i<obj.length;i++) {
Obj.options[i].selected = true;
}
}
function Dk_clearall (obj) {//Remove all options
if (obj.length-1>=0) {
for (Var i=obj.length-1;i>=0;i--) {
Obj.remove (i);
}
}
}
function Dk_removeone (obj) {//Delete selected items
for (Var i=obj.length-1;i>=0;i--) {
if (obj.options[i].selected) {
Obj.remove (i);
}
}
}
function Dk_checkexists (obj,val,txt) {//Check whether the item already exists
if (obj.length<0) return false;
for (Var i=0;i<obj.length;i++) {
if (obj.options[i].value==val && obj.options[i].text==txt) {
return true;
}
}
return false;
}
function Dk_listto (Src,obj,array) {//Show subclasses
if (array.length) {
var j=0;
for (Var i=0;i<src.length;i++) {
if (Src.options[i].sele