Auteur : Bits ordinaires [Yifan]
<HTML>
<TÊTE>
<META NAME="AUTHOUR" Content="DANNY KANG">
<META NAME="CreateDate" Content="2004-10-28">
<META NAME="Mots clés" Content="DANNY KANG,DannyKang,DK,[DK],pizz">
<META http-equiv=content-type content="text/html; charset=gb2312">
<langage SCRIPT=javascript>
//'+---------------------------------------------- ----
//'+ Nom du fichier :
//'+ Créé : 2004-10-28 .by pizz [DK]
//'+ Modifié : 2004-10-28 .by pizz [DK]
//'+ FuncDesc : Utilisez ASP et JAVASCRIPT pour réaliser l'affichage associé de plusieurs données de cases à cocher
//'+ www.downcodes.com
//'+---------------------------------------------
/ /Contenu de la première case à cocher
var DK_Array1 = nouveau tableau();
/*Les parties suivantes peuvent être générées dynamiquement à l'aide d'ASP*/
DK_Array1[DK_Array1.length]=new Array('1','Category 1'); //ID de catégorie, nom de catégorie
DK_Array1[DK_Array1.length]=new Array('2','Catégorie 2');
DK_Array1[DK_Array1.length]=new Array('3','Catégorie 3');
DK_Array1[DK_Array1.length]=new Array('4','Catégorie 4');
DK_Array1[DK_Array1.length]=new Array('5','Catégorie 5');
DK_Array1[DK_Array1.length]=new Array('6','Catégorie 6');
DK_Array1[DK_Array1.length]=new Array('7','Catégorie 7');
DK_Array1[DK_Array1.length]=new Array('8','Catégorie 8');
/////////////////////////////////////////////// /// /////
//Contenu de la troisième case à cocher
var DK_Array3 = nouveau tableau();
/*Les parties suivantes peuvent être générées dynamiquement à l'aide d'ASP*/
DK_Array3[DK_Array3.length]=new Array('1','1','Subclass 1.1'); //ID de catégorie, ID de sous-classe, nom de sous-classe
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){ //Ajouter un élément
if(DK_CheckExists(obj,val,txt)) {
alert('L'option existe déjà : ['+obj.id+']'+'n Valeur : '+ val+'n Texte : '+txt);
retour;
}
var opt=nouvelle Option();
opt.value=val;
opt.text=txt;
obj.options.add(opt,0);
}
function DK_InitListObject(obj,array){//Liste d'initialisation
si(tableau.longueur){
pour(var i=0;i<array.length;i++){
DK_AddOnTo(obj,array[i][0],array[i][1]);
}
}
autre {
alert('aucune donnée');
}
}
function DK_AddTo(src,obj){//Ajouter des options à la liste spécifiée
pour(var i=0;i<src.length;i++){
si(src.options[i].selected){
DK_AddOnTo(obj,src.options[i].value,src.options[i].text);
}
}
}
function DK_SelectAll(obj){ //Sélectionner toutes les options
pour(var i=0;i<obj.length;i++){
obj.options[i].selected = true;
}
}
function DK_ClearAll(obj){//Supprimer toutes les options
si(obj.length-1>=0){
pour(var i=obj.length-1;i>=0;i--){
obj.remove(i);
}
}
}
function DK_RemoveOne(obj){//Supprimer l'élément sélectionné
pour(var i=obj.length-1;i>=0;i--){
si(obj.options[i].selected){
obj.remove(i);
}
}
}
function DK_CheckExists(obj,val,txt){//Vérifier si l'élément existe déjà
if(obj.length<0) renvoie false ;
pour(var i=0;i<obj.length;i++){
if(obj.options[i].value==val && obj.options[i].text==txt) {
renvoie vrai ;
}
}
renvoie faux ;
}
fonction DK_ListTo(src,obj,array){//Afficher les sous-classes
si(tableau.longueur){
variable j=0 ;
pour(var i=0;i<src.length;i++){
si(src.options[i].selected){
j+=DK_AddSpecList(src.options[i].value,array,obj);
}
}
alert('Un total de sous-catégories '+j+' ont été trouvées.');
}
autre {
alert('aucune donnée');
}
}
function DK_AddSpecList(classid,array,obj){//Recherche de sous-classes
variable j=0 ;
pour(var i=0;i<array.length;i++){
if(array[i][0]==classid){
DK_AddOnTo(obj,array[i][1],array[i][2]);
j++;
}
}
retourner j;
}
</SCRIPT>
<STYLE type=text/css></STYLE>
<TITRE></TITRE>
</HEAD>
<CORPS>
<tableau>
<tr><td colspan=4><input type=button value='Coche une case d'initialisation' onclick='DK_InitListObject(select1,DK_Array1)'><br><br>
<tr><td>Cocher la première case : <td><select multiple id=select1 size=8></select>
<td><input type=button value='Add' onclick='DK_AddTo(select1,select2)'> ==>
<td>Cochez la deuxième case :<br><== <input type=button value='Delete' onclick='DK_RemoveOne(select2)'>
<input type=button value='Delete All' onclick='DK_ClearAll(select2)'>
<td><select multiple id=select2 size=8></select>
<td><input type=button value='Liste associée' onclick='DK_ListTo(select2,select3,DK_Array3)'> ==>
<td>Cochez la troisième case :<br><== <input type=button value='Delete' onclick='DK_RemoveOne(select3)'>
<input type=button value='Delete All' onclick='DK_ClearAll(select3)'>
<td><sélectionner plusieurs id=select3 size=8></select><br>
</table>
</CORPS>
</HTML>