# 100分求select三联级动态下拉代码,该如何处理(2)

www.MyException.Cn  网友分享于：2013-01-12  浏览：35次

}
}

fnGetCPCSubItems(objParObj,objSubObj,arrCPC,objParObj.value,0);
}

//先根
function fnGetCPCSubItems(objParObj,objSubObj,arrCPC,intParID,intLV){
var i;
var strCaption;

for(i=0;i <arrCPC.length;i++){
if(arrCPC[i][1] == intParID){
switch(intLV){
case 0:strCaption= " -- " + arrCPC[i][2];break;
case 1:strCaption= " -- " +arrCPC[i][2];break;
}

objSubObj.options[objSubObj.options.length]=new Option(strCaption,arrCPC[i][0]);
if(intLV <= 1)
fnGetCPCSubItems(objParObj,objSubObj,arrCPC,arrCPC[i][0],intLV+1)
}
}
}
</script>

<script language= "Javascript ">
//生成数组函数
function fnCreateArray(intHeight,intWidth){
var i,arrRet;
arrRet=new Array(intHeight);//生成数组的第一维

for(i=0;i <intHeight;i++){
arrRet[i] = new Array(intWidth);//生成数组的第二维
}
return arrRet;//返回生成的数组
}

//生成数组并赋值
/****第二层数组：Array-SecondLevel（数组）******/
var arrSecondLevel;
arrSecondLevel=fnCreateArray(9,3);
arrSecondLevel[0][0]= "0101 ";//value
arrSecondLevel[0][1]= "01 ";//父项value
arrSecondLevel[0][2]= "彩电 ";//text
arrSecondLevel[1][0]= "0102 ";
arrSecondLevel[1][1]= "01 ";
arrSecondLevel[1][2]= "冰箱 ";
arrSecondLevel[2][0]= "0103 ";
arrSecondLevel[2][1]= "01 ";
arrSecondLevel[2][2]= "音响 ";

arrSecondLevel[3][0]= "0201 ";
arrSecondLevel[3][1]= "02 ";
arrSecondLevel[3][2]= "内存 ";
arrSecondLevel[4][0]= "0202 ";
arrSecondLevel[4][1]= "02 ";
arrSecondLevel[4][2]= "处理器 ";
arrSecondLevel[5][0]= "0203 ";
arrSecondLevel[5][1]= "02 ";
arrSecondLevel[5][2]= "显示器 ";
arrSecondLevel[6][0]= "0204 ";
arrSecondLevel[6][1]= "02 ";
arrSecondLevel[6][2]= "鼠标 ";

arrSecondLevel[7][0]= "0301 ";
arrSecondLevel[7][1]= "03 ";
arrSecondLevel[7][2]= "书柜 ";
arrSecondLevel[8][0]= "0302 ";
arrSecondLevel[8][1]= "03 ";
arrSecondLevel[8][2]= "椅子 ";

/****第三层数组：Array-ThirdLevel（数组）******/
var arrThirdLevel;
arrThirdLevel=fnCreateArray(13,3);
arrThirdLevel[0][0]= "010101 ";//value
arrThirdLevel[0][1]= "0101 ";//父项value
arrThirdLevel[0][2]= "长虹 ";//text
arrThirdLevel[1][0]= "010102 ";
arrThirdLevel[1][1]= "0101 ";
arrThirdLevel[1][2]= "TCL ";
arrThirdLevel[2][0]= "010103 ";
arrThirdLevel[2][1]= "0101 ";
arrThirdLevel[2][2]= "创维 ";

arrThirdLevel[3][0]= "010201 ";
arrThirdLevel[3][1]= "0102 ";
arrThirdLevel[3][2]= "容星 ";
arrThirdLevel[4][0]= "010202 ";
arrThirdLevel[4][1]= "0102 ";
arrThirdLevel[4][2]= "海尔 ";

arrThirdLevel[5][0]= "010301 ";
arrThirdLevel[5][1]= "0103 ";
arrThirdLevel[5][2]= "创新 ";
arrThirdLevel[6][0]= "010302 ";
arrThirdLevel[6][1]= "0103 ";
arrThirdLevel[6][2]= "牙兰 ";

arrThirdLevel[7][0]= "020101 ";
arrThirdLevel[7][1]= "0201 ";
arrThirdLevel[7][2]= "金士顿 ";
arrThirdLevel[8][0]= "020102 ";
arrThirdLevel[8][1]= "0201 ";
arrThirdLevel[8][2]= "黑金刚 ";

arrThirdLevel[9][0]= "020201 ";
arrThirdLevel[9][1]= "0202 ";
arrThirdLevel[9][2]= "Intel ";